首页 > 解决方案 > 如何使用 Microsoft.Azure.Management.Fluent 在 Azure 存储帐户上设置最小 TLS;

问题描述

我正在使用 Microsoft.Azure.Management.Fluent C# 库创建用于预配 azure 资源的模板。

IAzure azure = Azure.Authenticate("./authfile.txt").WithDefaultSubscription();
var sa = await azure.StorageAccounts.Define(StorageAccount)
    .WithRegion(Region.USCentral)
    .WithExistingResourceGroup(ResourceGroup)
    .WithBlobEncryption()
    .WithGeneralPurposeAccountKindV2()
    .WithFileEncryption()
    .WithOnlyHttpsTraffic()
    .WithSku(StorageAccountSkuType.Standard_LRS)
    .WithHnsEnabled(true)
    .CreateAsync();

我希望我的存储帐户至少具有 TLS1.2,尽管我无法找到在此处设置所需 TLS 版本的方法。

如何在此处创建 TLS1.2 要求?

标签: c#azureazure-resource-manager

解决方案


这是 Fluent API 中的一个已知问题,请参考这个问题

您可以考虑使用非流利的 sdk:Microsoft.Azure.Management.Storage

例如:

        var storageManagementClient = new StorageManagementClient(azureCredentials)
        {
          SubscriptionId = subscriptionId
        };


        var storageAccountCreateParameters = new StorageAccountCreateParameters
        {
            //set the tls here.
            MinimumTlsVersion = "TLS1_2"

            //other settings.
        };

        await storageManagementClient.StorageAccounts.CreateAsync(resourceGroupName, accountName, storageAccountCreateParameters);
        

推荐阅读