azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[BUG] Null Response returned while trying to retrieve GeoReplicationStatistics property from StorageAccount
Library name and version
Azure.ResourceManager.Storage v1.1.0
Describe the bug
Hi,
I am getting null response while trying to retrieve LastSyncTime property of a storage account. The LastSyncOn roperty is part of GeoReplicationStatistics class under the StorageAccountData
I want to perform a failover action on a storage account for which I have to verify if LastSyncOn property is available before I trigger a failover action. But I see that GeoReplicationStats is retruned as null.

Expected behavior
When retrieving StorageAccountData.GeoiRelicationStats it should return an object which has information about the following properties
- CanFailover
- LastSyncOn
- Status https://learn.microsoft.com/en-us/dotnet/api/azure.resourcemanager.storage.models.georeplicationstatistics?view=azure-dotnet
Actual behavior
Getting a null response while trying to retrieve StorageAccountData.GeoRelicationStats
Reproduction Steps
For any storage account. Try accessing StorageAccountData and retrieve GeoReplicationStats propery.
StorageAccountResource.Data.GeoReplicationStats
Environment
No response
Thank you for your feedback. Tagging and routing to the team member best able to assist.
@svangipurapu-msft
When you retrieve the storage account from server, have you added the StorageAccountExpand.GeoReplicationStats.
The GeoReplicationStats won't be returned from server until you add this parameter like following code:
StorageAccountResource account2 = await storageAccountCollection.GetAsync(accountName, StorageAccountExpand.GeoReplicationStats)
@blueww
Thanks for the suggestion. I havent added it earlier. I modified my code and included StorageAccountExpand.GeoReplicationStats as below
Response<StorageAccountResource> operationResponse = await armClient.GetStorageAccountResource(new ResourceIdentifier(targetInfo.ResourceId)).GetAsync(StorageAccountExpand.GeoReplicationStats).ConfigureAwait(false);
Now this is throwing an exception when running this operation on a Storage account with SKU type as Standard_LRS. Is this an expected error? It is working fine, when running against a Storage Account with sku type as RA_GRS. Is it because Geo Replication Stats are only available for GRS account types?
@svangipurapu-msft
Yes, Geo Replication Stats are only available for GRS account types.
Thanks for the confirmation
@svangipurapu-msft
As your issue is already resolved, I will close this issue. Feel free to contact us again if need any assistance on Azure .net SDK.