【问题标题】:Upload SSL Certificate file (.fpx) for Azure web app using Azure SDK使用 Azure SDK 为 Azure Web 应用上传 SSL 证书文件 (.fpx)
【发布时间】:2020-10-11 16:25:08
【问题描述】:

如何使用 Azure SDK 为 Azure 应用服务上传“.pfx”文件(SSL 证书)?

Azure CLI (Certificates - Create Or Update)里面有个命令,但是想知道Azure SDK有没有什么功能。

【问题讨论】:

    标签: azure ssl ssl-certificate azure-sdk-.net


    【解决方案1】:

    如果要使用c# SDK创建SSL证书,请参考以下步骤

    1. 创建服务主体并将 Contributor 分配给 sp
    az login
    
    az ad sp create-for-rbac -n "MyApp" --role contributor \
        --scopes /subscriptions/{SubID} \
        --sdk-auth
    
    1. 代码
    string clientId = "<sp appid>";
                string clientSecret = "<sp password>";
                string tenantDomain = "<sp tenant>";
                string subscription = "";
                var creds= SdkContext.AzureCredentialsFactory.FromServicePrincipal(clientId, clientSecret, tenantDomain, AzureEnvironment.AzureGlobalCloud);
    
                var azure= Azure.Configure()
                    .WithLogLevel(HttpLoggingDelegatingHandler.Level.BodyAndHeaders)
                    .Authenticate(creds)
                    .WithSubscription(subscription);
    
               var res= azure.AppServices.AppServiceCertificates.Define("test")
                    .WithRegion(Region.AsiaEast)
                    .WithExistingResourceGroup("<group name>")
                    .WithPfxFile(@"<pfx file path>")
                    .WithPfxPassword("password")
                    .Create();
    

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-23
      相关资源
      最近更新 更多