2
votes

I am trying to connect to azure account storage from web application and i am getting the below error: " An exception of type -'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll but was not handled in user code

Additional information: The remote name could not be resolved: 'xxx.table.core.windows.net' "

I given only xxx in my config as accountname.

The same code i am able to access from console application.

i am using the below code to fetch the records from azure storage account.

string connStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connStr);

CloudTableClient client = storageAccount.CreateCloudTableClient();

CloudTable table = client.GetTableReference("ErrorLogs");

TableQuery<ErrorLogs> query = new TableQuery<ErrorLogs>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "ERROR"));

I have given web.config only the server name like xxxx but when tit tries to connect it's saying xxx.table.core.windows.net.

Below is the full exception details:

[WebException: The remote name could not be resolved: 'xxx.table.core.windows.net'] System.Net.HttpWebRequest.GetResponse() +1732 System.Net.HttpWebRequest.GetResponse() +600 Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync(RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) +2463

[StorageException: The remote name could not be resolved: 'xxx.table.core.windows.net'] Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync(RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext) +7418 Microsoft.WindowsAzure.Storage.Table.TableQuery1.ExecuteQuerySegmentedInternal(TableContinuationToken token, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext) +436 Microsoft.WindowsAzure.Storage.Table.<>c__DisplayClass7.b__6(IContinuationToken continuationToken) +141 Microsoft.WindowsAzure.Storage.Core.Util.d__01.MoveNext() +123 System.Linq.<TakeIterator>d__3a1.MoveNext() +400 System.Collections.Generic.List1..ctor(IEnumerable1 collection) +402 System.Linq.Enumerable.ToList(IEnumerable`1 source) +54

2
Can you share how your ConnectionString looks like? Please replace account name/key with some dummy values. Also check if you are not trying to connect with development storage account in your web application. - Gaurav Mantri
<add name="ConnString" connectionString="DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxx"/> - user970503
The above is the conenection string i am using in my web app and even console application. from console application it's working but not from web app. - user970503
Try cloud configuration instead of config manager if you hosting it in cloud.. this will be used to change the value at run time and u can test with different values - Mahesh Malpani

2 Answers

9
votes

I was stumped by the same error message until I came across this answer to an Azure Storage queues question:

https://stackoverflow.com/a/37604755/3507333

Turns out that Zone-Redundant Storage (ZRS) accounts DO NOT SUPPORT TABLES.

I created a new Locally-Redundant Storage (LRS) account and everything worked great!

0
votes

Hmmm not exactly sure what's happening here. I just created a test MVC app on Visual Studio and had no problems. Here's how I set up everything...

Web.config:

<appSettings>
    <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxxx" />
</appSettings>

Connection string code:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));