These are high-level notes from Troy Hunt's excellent blog post and the official Let's Encrypt Site Extension documentation.
Important: The LetsEncrypt site extension is currently buggy. Despite that it still works. Some errors we can simply ignore. We've done the following process on a few Azure Web Apps and each time some troubleshooting is necessary.
The following example sets up SSL for an App Service (named sapling) in an App Service Plan (named DefaultServerFarm). The App Service and App Service Plan are in different resource groups:
- App Service sapling is in the TreeGame Resource Group.
- App Service Plan DefaultServerFarm is in the Default-Web-WestUS Resource Group.
Note: Following these steps requires some thinking on your part... they are intentionally high level to respect your intelligence.
With that in mind, here are the steps we followed.
0. Add custom domain(s) to your Web App
This is fairly common Azure Web App knowledge, so I will not get into it here. It involve buying a custom domain name and wiring it via a CNAME or A record to the Azure Web App. Recommendation: use a CNAME unless you have a good reason to use an A record.
1. Setup Active Directory: add a server principal
Do this once per Active Directory tenant. So far we've needed only one tenant and that has been our default tenant.
- Azure Active Directory
- Classic Portal
- Add (this is a button near the bottom)
- Copy Client ID. (we'll use this later).
- Keys > 2 years > Save > Copy (we'll use this later too).
Note: It is worth saving the ClientID and Key in a safe place. Alternatively, generate a new key each time we add SSL to a new Web App. To generate a new key, follow the step above until the
Applications step and then.
LetsEncrpt(you've already created it).
- Copy the Client ID.
- Generate and copy a new 2 year key.
2. Setup each Resource Group: give access to the server principal
Do this once per resource group. Since we have our Web App and App Service Plan living in separate Resource Groups, we needed to do this step twice.
- Resource Groups
- For both DefaultWeb-WestUS and TreeGame
- Access Control (IAM)
- Select > OK
3. Setup the Web App - add the site extension
Do this once per Web App that needs SSL.
Note: This is where the process become buggy and requires some creativity and persistence for it to succeed.
- From the Service Control Manager (https://sapling.scm.azurewebsites.net)
- Site Extensions > Gallery
- Search for Lets Encrypt
- Install the 32-bit extension
- 64-bit explodes
- Restart the site
- there is button at the top right
4. Setup the site extension
- Service Control Manager.
- Site Extensions > Installed
- Launch the site extension
- Set it up as follows:
- Tenant mydirectory.onmicrosoft.com (find this in the top right corner of portal.azure.com)
- SubscriptionId my-sub-script-ion-id (find this in the app service's overview page)
- Client ID the Client ID of the LetsEncrypt Active Directory app that we created
- Client Secret the Client Secret of the LetsEncrypt Active Directory app (its okay to create a new key if we lost it).
- Resource Group Name TreeGame (i.e. use the Web App's Resource Group not the App Service Plan's one).
- Service Plan Resource Group Name Default-Web-WestUS (here is where we use the App Service Plan's).
- Use IP Based SSL false
- Web App Name sapling (this is usually auto-filled)
- Site Slot Name blank (unless your using a slot).
- Update application settings true
- Click Next. If there is an error such as
'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...), simply refresh the page to resolve it.
- Click Next again to request and install a certificate.
- Hostnames will be auto-filled with the App Service's custom domain name(s).
- Email Add your email.
- Use Staging false
- Click Request and Install certificate. This might take a few minutes.
- This might time outl if it does simply refresh the page; it has probably succeeded.
https:// URL associated with the hostnames from the most recent step. If it works, then you have succeeded!
Also visit the Environment page in the SCM, which will list all the
letsencrypt related environment variables.