Azure Website – configure SSL Bindings with PowerShell or cross-platform CLI

Question:

Our situation is that we expect to be frequently adding new custom sub-domains to a number of Azure Websites and we need to be able to automate the process so we can minimize any need for manual intervention and the risk of screwing something up.

The Azure Cross-Platform CLI tools and PowerShell cmdlets provide enough functionality for me to script it all out, with the apparent exception of the SSL bindings… The websites are all HTTPS-only, and every domain that we add requires an SNI SSL binding.

The Azure management portals allow you to manually configure the SSL bindings for a website’s domains. How can I achieve the same using the PowerShell cmdlets or the cross-platform CLI tools? If it’s not possible using either of those tools, is there some other way I can script out the process for when we add/remove domains to the sites?

Answer:

I’ve finally managed to successfully do this by using the Azure Web Sites Management REST API.

The original documentation which I based my example code below on back in 2014 is no longer available, but the Azure Resource Explorer which Zain mentioned and linked to a blog post about in the comments is in my opinion a superior resource. Direct link: https://resources.azure.com/

The Service Management REST API Reference appears to be the closest thing to the original documentation I used but presently lacks anything specifically about Azure Web Apps (previously known as Azure Websites): https://msdn.microsoft.com/library/azure/ee460799.aspx

E.g.:

Source:

Azure Website – configure SSL Bindings with PowerShell or cross-platform CLI by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply