I am working on a new web app and I am trying to connect to an existing Azure table storage.
using System.Web.Mvc;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
namespace WebApplication3.Controllers
{
public class GetEmailAddressesController : Controller
{
public ActionResult Address()
{
string emails = "";
// Parse the connection string and return a reference to the storage account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("________"));
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("experimentsEmailAddresses");
// Construct a table query.
TableQuery<TableData> query = new TableQuery<TableData>();
foreach (TableData entity in table.ExecuteQuery(query))
{
emails += entity.Email + ";";
}
ViewBag.Message = " " + emails;
return View();
}
}
}
The code will compile but when I run it on debug mode I get an error:
System.ArgumentNullException: 'Value cannot be null. Parameter name: connectionString'
i.e. my connection string isn't valid, although I copied it from the Access keys in Azure.
What is the best solution for that?