1
votes

I have enabled RA-GRS replication on my Azure storage table service. Is there a option to read from secondary when even there is no failover. What changes need to be done in connection string other than appending -secondary in account name?

2
Are you consuming Storage REST API directly or using some kind of SDK (.Net for example)?Gaurav Mantri
I am using .NET SDK. I changed the connection string by appending -secondary and tried a read. It throws an exception saying "403 forbidden" authentication failed.Shetty

2 Answers

2
votes

Read-access geo-redundant storage (RA-GRS) does indeed allow you to read from the secondary endpoint without a failover event. To do this, you'll need to append secondary to the account name in your connection string. It should look something like youraccount-secondary.table.core.windows.net.

0
votes

If you're using .Net SDK, you don't have to manually append -secondary to the account name. To connect to a secondary endpoint, you can make use of TableRequestOptions.LocationMode property and that will automatically connect to the secondary endpoint.

Take a look at the code sample below. It lists tables in a storage account from secondary location:

    static void ConnectToSecondary()
    {
        var cred = new StorageCredentials(accountName, accountKey);
        var account = new CloudStorageAccount(cred, true);
        var client = account.CreateCloudTableClient();
        var requestOptions = new TableRequestOptions()
        {
            LocationMode = Microsoft.WindowsAzure.Storage.RetryPolicies.LocationMode.SecondaryOnly
        };
        var tables = client.ListTables(null, requestOptions);
        foreach (var table in tables)
        {
            Console.WriteLine(table.Uri.AbsoluteUri);
        }
    }

and here's the output from fiddler:

GET https://account-secondary.table.core.windows.net/Tables HTTP/1.1
User-Agent: Azure-Storage/7.0.0 (.NET CLR 4.0.30319.42000; Win32NT 6.2.9200.0)
x-ms-version: 2015-07-08
Accept-Charset: UTF-8
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json;odata=minimalmetadata
x-ms-client-request-id: 0f123ca9-1f35-4e46-9590-ebca0912baa8
x-ms-date: Fri, 11 Nov 2016 10:59:14 GMT
Authorization: SharedKey account:sEsvrm3W0Tn7QhkHqHDrS5o2IvldI4NVUL4U276JudQ=
Host: account-secondary.table.core.windows.net
Connection: Keep-Alive