【发布时间】: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
如何使用 Azure SDK 为 Azure 应用服务上传“.pfx”文件(SSL 证书)?
Azure CLI (Certificates - Create Or Update)里面有个命令,但是想知道Azure SDK有没有什么功能。
【问题讨论】:
标签: azure ssl ssl-certificate azure-sdk-.net
如果要使用c# SDK创建SSL证书,请参考以下步骤
Contributor 分配给 spaz login
az ad sp create-for-rbac -n "MyApp" --role contributor \
--scopes /subscriptions/{SubID} \
--sdk-auth
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();
【讨论】: