Issue with Web App certificate & ssl binding
See original GitHub issueThere is an issue when attempting to create and bind a certificate to a web app when the webapp is in a different resource group to the App Service Plan.
The following code works when both are in the same resource group, however it fails when they are in different resource groups.
var webApp = await azure.WebApps.GetByIdAsync(webAppId); webApp.Update() .DefineSslBinding() .ForHostname(domainName) .WithPfxCertificateToUpload(certFileName, cert.Password) .WithSniBasedSsl() .Attach() .DefineSslBinding() .ForHostname("www." + domainName) .WithPfxCertificateToUpload(certFileName, cert.Password) .WithSniBasedSsl() .Attach() .Apply();
The error message is “: Microsoft.Rest.Azure.CloudException: Certificate XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX was not found.”
When using the resource explorer, I can see the certificate has been uploaded to the Web App resource group instead of the App Service Plan resource group:
So when the actual binding of the domain name to the ssl cert occurs, the certificate isn’t there so the above error is given.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top GitHub Comments
A fully working workaround is this:
@sagoo33 Yep ! This checks out !
In hindsight, Not that weird to use the appservice plan ressource name to upload the cert. But it would be nice to have this in the documentation of the library. If app ressource group is different from app service plan’s, it will definitely lead to this ‘Not Found’ behavior if you are not careful where you upload. Therefore the Azure credentials used must have access to both resource group