Reputation: 1003
I'm getting the following error when I try to get the account:
System.Runtime.InteropServices.SEHException
The Conn in configurations are:
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WindowsAzureProject3" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2013-10.2.2">
<Role name="manager">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Conn" value="DefaultEndpointsProtocol=https;AccountName=name;AccountKey=key"></Setting>
</ConfigurationSettings>
</Role>
<Role name="detectrod">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="DataConnectionString" value="DefaultEndpointsProtocol=https;AccountName=name;AccountKey=key"></Setting>
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
(the account keys are correct)
and the line with error is:
var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
Upvotes: 0
Views: 1666
Reputation: 9499
This error typically happens if your azure code is locally run without the context of azure app fabric or storage account. i.e. A ROLEENVIRONMENT is not available.
Check if you're not running the code under the context of normal ASP.net context. This could happen if CloudProject is not the startup project and if you directly started the role project.
RoleEnvironment.IsAvailable
.to verify use this code:
CloudStorageAccount account = null;
if (RoleEnvironment.IsAvailable)
{
account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
// also try
// account = CloudStorageAccount.DevelopmentStorageAccount;
}
else
{
// not in cloud context.
}
Upvotes: 3