App Service Managed Certificates error #5006
-
I've run into a problem when deploying a bicep script with an web app, DNS crecord (in Azure), host name binding and eventually a app service managed certificat. Deployment always fails when creating the certificat.
I have a similar script for setting up an Function App - only diffrerence is that this script creates the app service plan also, while this one uses an existing ASP. Facts:
The module for creating the managed certificate is the following:
Any help og hints to solving this is greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 63 replies
-
There is a chain of dependencies needed for this to work. Essentially you can get the free cert if you have mapped the DNS name alias to the WebSite used in the AppService. https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain?tabs=cname Before you can map the domain, you need to prove that you own it. If you have these steps covered, let me know and we can move onto the next part. |
Beta Was this translation helpful? Give feedback.
-
@brwilkinson - ok - got a stripped copy of the code publish on my GH account -> https://github.com/jnus/bicep-managed-cert-error The domain being used, in this case segeswebsites.net, is managed by Azure DNS and as you also pointed out, it actually works if I do the last couple of steps in the portal. It looks like a delay issue, since the cert is created and ready to use. |
Beta Was this translation helpful? Give feedback.
-
Hi @brwilkinson - been going forth and back regarding this issue, looking for an error 40 from my end. Still haven't identified the problem. Create certificate prior to the host binding
Minimal example producing the error: https://github.com/jnus/bicepManagedCertificate/blob/master/certificate-creation-requires-hostname.bicep I've got a working example for a function app using the approach specifiered here -> https://wp.sjkp.dk/taking-azure-bicep-for-a-spin/ Basically the following approach:
|
Beta Was this translation helpful? Give feedback.
-
First of all, appreciated you hanging in there. There's definitely some life cycle regarding bicep/ARM that I haven't quite figured out yet. Changing the order to your example:
With this approach, I get the error Changing it to the numbering in your post above gives the samme error.
My example is located here -> https://github.com/jnus/bicep-managed-cert-error Question: |
Beta Was this translation helpful? Give feedback.
-
Hm - that's interesting. The error I'm getting from az is: Looking in the activity log for the resource groups, I see 5 error: Anyway to see more verbose logging for deployment? |
Beta Was this translation helpful? Give feedback.
-
To summarize this thread/discussion. You can deploy a free Certificate for your web app as documented here: The steps are:
Example here: Since step 3 and 5 share the same resource type, using a module to call it twice. Input for the above template is below. "FunctionInfo": [
{
"Name": "DIS02",
"kind": "functionapp",
"AppSVCPlan": "ASP01",
"saname": "data",
"runtime": "dotnet",
"subnet": "snMT01",
"preWarmedCount": 1,
"customDNS": 1,
"initialDeploy": 1 // <-- leave this as 1 to start then set it to 0 anytime later.
}
] The issue behind this thread was related to having an old App Service Plan/ServerFarm, so you likely want to deploy your ServerFarm to ensure it has been deployed with some recent API to ensure this works successfully.
@jnus let us know if you have any additional information after your investigation into your App Service Plan. |
Beta Was this translation helpful? Give feedback.
-
Hello, I have a follow up to this discussion. The issue I'm facing is that I want to run the same code for subscription with custom domain and without, and I can't make conditional checks to work correctly. Same bicep code does not work for resources with custom and without custom binding, despite I added conditional statements all over the place for involved. I ended up creating this construction:
Which is slightly rewritten version of @brwilkinson examples The problem is that certificate module will still be invoked, go over resources it has to create - conditional
Any thoughts how can I resolve this situation and create code which will be working correctly for both cases - webapp with custom domain and webapp without one ? |
Beta Was this translation helpful? Give feedback.
-
Automating custom domains with TLS/SSL using ARM/Bicep/Terraform is honestly a pretty bad experience. It shouldn't be anywhere near this hard (should it?). The documentation and examples aren't doing much to help either. Are there any plans to improve the situation? |
Beta Was this translation helpful? Give feedback.
-
@janaka Custom domains with Azure App Service or in general? There's one part that is Resource Provider specific, and one part about domains/certs in general. Automating this with App Service is definitely harder than it should be. But there are some moving pieces underneath that contribute - if you've attempted hooking the App Service up to a private vnet you'll have noticed you need one inbound subnet and another for outbound traffic. Hence, this complication carries over to certificate enrollment which requires public line of sight reachable IP address for issuing a cert. If you look at a newer service (with a newer Resource Provider) like Container Apps it's also much easier to do both vnet integration and custom domains + certs. You can still trip it up by forgetting to do the DNS records correctly, but still less hard. Other than the Bicep team slapping the resource teams when they come up with non-IaC friendly services there's not much we can do I suppose... |
Beta Was this translation helpful? Give feedback.
-
Hi guys,
I tried this but the certificate does not exist - because it is in keyVault?!
I tried this but this does not deliver a thumbprint.
What I am missing is a resource named ceritficate, similar to this but ../certificates@.. This just don't exists whyoever:
What do I have to use instead to get easily an existing cert to use its thumbprint? Thank you for your help @brwilkinson `` |
Beta Was this translation helpful? Give feedback.
To summarize this thread/discussion.
You can deploy a free Certificate for your web app as documented here:
https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate#create-a-free-managed-certificate
The steps are:
Example here:
I updated this: https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/x.appService.bicep#L66
Since step 3 and 5 share the same resource type, using a module to call it twice.
added this: https://github.com/brwilkins…