Reputation: 31
We can set if secure tansfer is enabled or not when creating storage account in azure portal but is there a way to check if a storage account is enabled or not through api/sdk?
Upvotes: 0
Views: 1066
Reputation: 11
You can get this information in multiple ways depending on your preference:
Here are the snippets reduced to only display the value of the field. Replace the placeholders <..> with their real values. The storage account will be identified by resource group name and storage account name. The solutions presume that you now how to authenticate.
az storage account show --resource-group <ResourceGroupName> --name <StorageAccountName> --query enableHttpsTrafficOnly
Get-AzStorageAccount -ResourceGroupName <ResourceGroupName> -Name <StorageAccountName> | Select-Object EnableHttpsTrafficOnly
//requires references for Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.Storage.Fluent
IAzure myAzure = Azure.Authenticate("azure.auth").WithDefaultSubscription();
Console.WriteLine(myAzure.StorageAccounts.GetByResourceGroup("<ResourceGroupName>", "<StorageAccountName>").Inner.EnableHttpsTrafficOnly);
There is also an SDK for Java and it seems to work in an identical fashion. Looking at the code, you should be able to achieve the same, as with the .NET SDK.
Here is a link for storage account management samples with Java and the SDK: Java SDK Storage Account Management Go to the section List storage accounts and adapt the sample similar to my C# code (apply getByResourceGroup(...) and .Inner.enableHttpsTrafficOnly
I hope this is of some help.
Upvotes: 1
Reputation: 136366
Yes, it is possible to do so. If you're using Storage Resource Provider's Get Properties
operation on a storage account, you will see a property called supportsHttpsTrafficOnly
. True value indicates that secure transfer is enabled and false value indicates it otherwise.
I have not used Java SDK but a quick look at StorageAccount
class indicates that this capability is exposed through enableHttpsTrafficOnly()
property. So it should be possible to get this information through SDK as well.
Upvotes: 1