如何以编程方式将现有SSL证书应用于Azure Web应用 [英] How to programatically apply an existing SSL certificate to an Azure web app

查看:95
本文介绍了如何以编程方式将现有SSL证书应用于Azure Web应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Azure Fluent Management API 自动化我们的部署过程.到目前为止,我的问题很少.

I'm using the Azure Fluent Management API to automate our deployment process. Up until now, I've had minimal problems.

我们已经将SSL证书上载到Azure,并且可以通过Azure门户手动将它们绑定到网站.但是我找不到以编程方式执行此操作的机制.

We have SSL certificates already uploaded into Azure and can manually bind them to a web site through the Azure portal. But I can't find a mechanism for doing this programmatically.

我可以在下面和文档中找到最接近的文档

The closest I can find is below and in the documentation here.

webApp.Update()
    .DefineSslBinding()
    .ForHostname(domainName)
    .WithPfxCertificateToUpload(pfxFile, password)
    .WithSniBasedSsl()
    .Attach();

但是,这显然是在上传新证书,而不是使用现有证书. ForHostName()调用之后还有两个其他选项:

However, this is obviously uploading a new certificate, not using an existing one. There are two other options after the ForHostName() call:

WithExistingAppServiceCertificateOrder(certificateOrder)

WithNewStandardSslCertificateOrder(certificateOrderName)

但是我的理解是,这些与通过Azure/Microsoft购买证书有关.

But my understanding is that these are related to purchasing the certificates through Azure/Microsoft.

我也看不到REST API中的任何内容文档.

I also can't see anything in the REST API documentation.

那么,如何用代码将现有证书与Web应用程序关联起来?

So, how can I associate an existing certificate with a web app, in code?

推荐答案

很明显,鉴于我只找到了

Obviously this was not critical given I've only found an answer 9 months later.

无论如何,下面的答案是从提供的链接中复制的.

Anyhow, the answer below is copied from the link provided.

await azure
        .WebApps
        .Inner
        .CreateOrUpdateHostNameBindingWithHttpMessagesAsync(
            resourceGroupName, 
            webAppName, 
            domain,
            new HostNameBindingInner(
                azureResourceType: AzureResourceType.Website,
                hostNameType: HostNameType.Verified,
                customHostNameDnsRecordType: CustomHostNameDnsRecordType.CName,
                sslState: SslState.SniEnabled,
                thumbprint: thumbprint));

这篇关于如何以编程方式将现有SSL证书应用于Azure Web应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆