admin管理员组文章数量:1245868
Note: the answer may be in either VB.NET or C#. I have no preference for this Q&A.
How do we go about binding a Managed Certificate to a Custom Domain using the new SDK?
Unfortunately, the samples don't cover this task. (In fact, they don't compile, with hundreds of broken references, so it's impossible to tell whether they're even accurate.)
And the documentation isn't very helpful, either. There's this guidance, and this, but those appear to be for purchased certificates. Nothing in that namespace mentions a Managed Certificate.
Here's the problem.
I've been able to successfully add a Custom Domain to my Azure App Service, using this code:
Dim tenantId As String = "89C4A752-7028-4F94-BF6D-A5B0AB83A30A"
Dim clientId As String = "AC4E5551-B056-4769-84AD-F7016E289122"
Dim clientSecret As String = "EJY5du3PVx#o2P3b*B^25t@LoVu8LX2Lgo"
Dim resourceGroupName As String = "group"
Dim webAppName As String = "site"
Dim customDomain As String = "example"
' Authenticate and get the client
Dim credential = New ClientSecretCredential(tenantId, clientId, clientSecret)
Dim armClient = New ArmClient(credential)
' Get the web app
Dim subscription = armClient.GetDefaultSubscriptionAsync.Result
Dim resourceGroup = subscription.GetResourceGroups.Get(resourceGroupName)
Dim webApp = resourceGroup.Value.GetWebSites.Get(webAppName)
' Set the domain properties
Dim domainProperties = New HostNameBindingData With {
.CustomHostNameDnsRecordType = CustomHostNameDnsRecordType.A,
.HostNameType = AppServiceHostNameType.Managed
}
Me.UpdateDns(webApp)
Dim op = webApp.Value.GetSiteHostNameBindings.CreateOrUpdate(Azure.WaitUntil.Completed, customDomain, domainProperties)
That works. The domain is added. But it's not bound to anything.
Adding a binding to a Managed Certificate is another matter entirely. I tried setting the .SslState
property, like so:
Dim domainProperties = New HostNameBindingData With {
.CustomHostNameDnsRecordType = CustomHostNameDnsRecordType.CName,
.HostNameType = AppServiceHostNameType.Managed,
.SslState = HostNameBindingSslState.SniEnabled
}
...but that results in an error:
Parameter Thumbprint is null or empty.
There is a .ThumbprintString
property on the HostNameBindingData
class, but where do we get that value from?
The repo referenced in this answer almost gets there, but it's nine years old and we're on a completely revamped SDK by now. Besides, he's uploading a .PFX, which is something completely different.
How do I create a new Managed Certificate and bind it to my newly added Custom Domain?
--EDIT--
In fact, they don't compile, with hundreds of broken references, so it's impossible to tell whether they're even accurate.
I got the source to build; it was a lot easier than I'd expected. All it needed was installation of the specific .NET SDK version indicated in the Global.json
file in the repo root.
Oh... and an appropriate Package Source Mapping entry, assuming that's in use.
本文标签: netHow to bind a Managed Certificate using the Azure SDKStack Overflow
版权声明:本文标题:.net - How to bind a Managed Certificate using the Azure SDK? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740252652a2248785.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论