[英]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?在 azure 门户中创建存储帐户时,我们可以设置是否启用了安全传输,但是有没有办法通过 api/sdk 检查存储帐户是否启用?
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. Java 还有一个 SDK ,它似乎以相同的方式工作。 Looking at the code, you should be able to achieve the same, as with the .NET SDK.
查看代码,您应该能够实现与 .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 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.我希望这会有所帮助。
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
.如果您在存储帐户上使用存储资源提供程序的
Get Properties
操作,您将看到一个名为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.我没有使用过 Java SDK 但快速查看
StorageAccount
class 表明此功能通过enableHttpsTrafficOnly()
属性公开。 So it should be possible to get this information through SDK as well.所以应该也可以通过 SDK 获得这些信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.