Azure Cloud Storage Account Connection String

How to create a connection string to a cloud storage account so that I can access tables, blocks and queues? Sample code is evaluated.

+6
source share
3 answers

Noting this because it’s Google’s top and the information is no longer relevant.

You can configure CloudStorageAccount through the connection string passed from FromConfigurationSetting() .

You build the configuration line in the following order: https://docs.microsoft.com/en-gb/azure/storage/common/storage-configure-connection-string

There's also an assistant in the IDE if you right-click on a role.

+9
source

You do not create a connection string as such for Azure Cloud Storage, you get access to this service (the same with blobs and queues) through the API, MS provides a soap API and a REST API for this.

You download the Windows Azure SDK for samples and tools (and Azure Fabric if you want to test locally), you can get here .

SQL Azure is different, SQL Azure is "SQL Server in the clouds", and for this service you just need a connection string, very similar to a regular SQL Server connection string.

+1
source

Link: Azure documentation

Connection string for Azure storage account:

DefaultEndpointsProtocol=[http|https];AccountName=myAccountName;AccountKey=myAccountKey

example:

 DefaultEndpointsProtocol=https;AccountName=storagesample;AccountKey=<account-key> 

Connection string to the storage emulator:

config.xml

 <appSettings> <add key="StorageConnectionString" value="UseDevelopmentStorage=true" /> </appSettings> DefaultEndpointsProtocol=http;AccountName=testacc1; AccountKey=1gy3lpE7Du1j5ljKiupgKzywSw2isjsdfdsfsdfsdsgfsgfdgfdgfd/YThisv/OVVLfIOv9kQ==; BlobEndpoint=http://127.0.0.1:8440/testacc1; TableEndpoint=http://127.0.0.1:8440/testacc1; QueueEndpoint=http://127.0.0.1:8440/testacc1; 

Example:

  <connectionStrings> <add name="AzureStorageAccount" connectionString="DefaultEndpointsProtocol=https;AccountName=testdata;Accoun‌​tKey=1gy3lpE7Du1j5ljKiupgKzywSw2isjsdfdsfsdfsdsgfsgfdgfdgfd/YThisv/OVVLfIOv9kQ==;"/> </connectionStrings> 

But sometimes it will not work and will be due to an error

 An unhandled exception of type 'System.FormatException' occurred in Microsoft.WindowsAzure.Storage.dll Additional information: No valid combination of account information found. 

then please try with the code below: checked and works 100%

 var accountName = "test2rdsfdg462"; var keyValue = "1gy3lpE7Du1j5ljKiupgKzywSfsdfdsfsdfsdfsdfsdfsdqGxd7/YThisv/OVVLfIOv9kQ=="; var useHttps = true; var connValid = true; var storageCredentials = new StorageCredentials(accountName, keyValue); var storageAccount = new CloudStorageAccount(storageCredentials, useHttps); var conString = storageAccount.ToString(connValid); CloudStorageAccount sa = CloudStorageAccount.Parse(connString); 
+1
source

Source: https://habr.com/ru/post/1302436/


All Articles