drn
drn

Reputation: 31

Check if secure transfer is enabled in azure storage account

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

Answers (2)

Zethuil
Zethuil

Reputation: 11

You can get this information in multiple ways depending on your preference:

  • Azure CLI
  • Azure PowerShell
  • .Net Fluent SDK
  • Java SDK
  • and other SDKs that exist

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.

Azure CLI

az storage account show --resource-group <ResourceGroupName> --name <StorageAccountName> --query enableHttpsTrafficOnly

Azure PowerShell

Get-AzStorageAccount -ResourceGroupName <ResourceGroupName> -Name <StorageAccountName> | Select-Object EnableHttpsTrafficOnly

Fluent SDK (C# console app)

//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);

Java SDK

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

Gaurav Mantri
Gaurav Mantri

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

Related Questions