Skip to content

Commit af4542a

Browse files
committed
Fix title typo and improve code formatting in App Services Managed Certificates post
1 parent c65810e commit af4542a

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

_posts/2023-10-31-App-Services-Managed-Certificates.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
---
2-
title: "Create a (free!) App Services Managed Managed Certificates with Bicep"
2+
title: "Create a (free!) App Services Managed Certificates with Bicep"
33
date: 2023-10-30 00:00:00 +1000
44
categories: Azure
55
tags:
66
- Azure
77
- Bicep
88
excerpt_separator: <!--more-->
99
---
10-
11-
## Create a (free!) App Services Managed Certificate with Bicep
12-
1310
An certificates in Azure App Services is bind to an host name, this can be an apex (or naked) domain (<https://robertdeveen.com>) or a subdomain (<https://www.robertdeveen.com> or <https://subdomain.robertdeveen.com>), or a combination of these two (for example one certificate for <https://robertdeveen.com> and <https://www.robertdeveen.com>).
1411

1512
To create an App Services Managed Certificate there are two ways to create a certificate with Bicep. One for a apex domain and one for an subdomain. The validation of the ownership of the domain is the main difference. To generate a certificate the certificate authority would like to validate that the domain you try to get a certificate for is yours. That you are the owner of that (sub)domain name.
@@ -20,7 +17,7 @@ As a prerequisite you need to have an App Service Plan and an App Service or Fun
2017

2118
## Create a Host Name binding without a certificate
2219

23-
```Bicep
20+
{% highlight bicep %}
2421
param customHostname string = 'www.robertdeveen.com'
2522
param webAppName string = 'robertdeveen'
2623

@@ -35,8 +32,7 @@ resource hostNameBindingWithoutCertificate 'Microsoft.Web/sites/hostNameBindings
3532
sslState: 'Disabled'
3633
}
3734
}
38-
39-
```
35+
{% endhighlight %}
4036

4137
## Create a App Services Managed Certificate for a subdomain
4238

@@ -46,12 +42,11 @@ In the DNS Zone, create a CName record pointing to *.azurewebsite.net. This is n
4642

4743
| Type | Record | Value |
4844
| --- | --- | --- |
49-
| CName | www.robertdeveen.nl | robertdeveen.azurewebsites.net |
45+
| CNAME | www.robertdeveen.com | robertdeveen.azurewebsites.net |
5046

5147
### Create a App Services Managed Certificate
5248

53-
```Bicep
54-
49+
{% highlight bicep %}
5550
param canonicalName string = 'www.robertdeveen.com'
5651
param appServicePlanName string = 'robertdeveen-plan'
5752
param location string = 'westeurope'
@@ -70,7 +65,7 @@ resource certificate 'Microsoft.Web/certificates@2022-03-01' = {
7065
canonicalName: canonicalName
7166
}
7267
}
73-
```
68+
{% endhighlight %}
7469

7570
> Note: The documentation is not clear about the meaning of the `domainValidationMethod` field, it is a string. But the value that is accepted should be `cname-delegation` or `http-token`. Other values give the error message: **"The parameter Properties.DomainValidationMethod has an invalid value."**
7671
The value `cname-delegation` is the only one working these days. The value `http-token` is not working anymore and just waiting a long time to end. The best solution is to not add that field.
@@ -83,9 +78,9 @@ In the DNS Zone, create an A records pointing to the IP address of the webapp. T
8378

8479
| Type | Record | Value |
8580
| --- | --- | --- |
86-
| A | robertdeveen.nl | IP-address-of-webapp |
81+
| A | robertdeveen.com | IP-address-of-webapp |
8782

88-
```bicep
83+
{% highlight bicep %}
8984
param canonicalName string = 'robertdeveen.com'
9085
param location string = 'westeurope'
9186

@@ -97,13 +92,13 @@ resource nakedCertificate 'Microsoft.Web/certificates@2022-09-01' = {
9792
canonicalName: canonicalName
9893
}
9994
}
100-
```
95+
{% endhighlight %}
10196

10297
## Create a App Services Managed Certificate for an apex and subdomain
10398

10499
**THIS DOESN'T WORK!** The documentation is not clear about this, but it is not possible to create a certificate for an apex and subdomain at the same time. You need to create two certificates, one for the apex and one for the subdomain.
105100

106-
```bicep
101+
{% highlight bicep %}
107102
// param canonicalName string = 'robertdeveen.com'
108103
// param hostNames = [ 'www.robertdeveen.com', 'robertdeveen.com' ]
109104
// param location string = 'westeurope'
@@ -117,13 +112,13 @@ resource nakedCertificate 'Microsoft.Web/certificates@2022-09-01' = {
117112
// canonicalName: canonicalName
118113
// }
119114
// }
120-
```
115+
{% endhighlight %}
121116

122117
## Bind certificate to the host name
123118

124119
We need to use a module to enable the certificate on the host name, as Bicep/ARM forbids using resource with this same type-name combination twice in one deployment.
125120

126-
```Bicep
121+
{% highlight bicep %}
127122
module hostnameBindingWithCertificate './modules/hostname-binding.Bicep' = {
128123
name: '${customHostname}-hostnamebinding'
129124
params: {
@@ -132,11 +127,11 @@ module hostnameBindingWithCertificate './modules/hostname-binding.Bicep' = {
132127
webAppName: webAppName
133128
}
134129
}
135-
```
130+
{% endhighlight %}
136131

137132
### `./module/hostname-binding.Bicep`
138133

139-
```Bicep
134+
{% highlight bicep %}
140135
resource hostNameBindingWithCertificate 'Microsoft.Web/sites/hostNameBindings@2022-03-01' = {
141136
name: '${webAppName}/${customHostname}'
142137
properties: {
@@ -145,4 +140,4 @@ resource hostNameBindingWithCertificate 'Microsoft.Web/sites/hostNameBindings@20
145140
thumbprint: certificateThumbprint
146141
}
147142
}
148-
```
143+
{% endhighlight %}

0 commit comments

Comments
 (0)