Reputation: 67
I want to add 100+ custom domains on single azure web app, each domain will have it's own SSL certificate (downloaded from cloudflare).
Is there a way to upload 100+ pfx certificate files from azure cli against each custom domain in one go?
Ex: abc.com with it's own ssl certificate xyz.com with it's own ssl certificate
I will be required to add custom domains & their ssl certificates in bulk.
Currently, I can upload 1 pfx to the app with this command:
New-AzWebAppSSLBinding -WebAppName WebApiStaging -Name devops.prod.xyz -ResourceGroupName Staging -CertificateFilePath C:\prod.pfx -CertificatePassword XXXXXX -SslState SniEnabled
Please suggest the possible options. Thanks
Upvotes: 0
Views: 537
Reputation: 174690
Let's take a look at the variable parts of the command you're using:
New-AzWebAppSSLBinding -WebAppName WebApiStaging -Name devops.prod.xyz -ResourceGroupName Staging -CertificateFilePath C:\prod.pfx -CertificatePassword XXXXXX -SslState SniEnabled
Since it's multiple bindings for a single application, the -WepAppName
and -ResourceGroupName
will remain the same, and I assume you'll want to enable SNI for all bindings too - which leaves us with:
-Name <domain fqdn>
-CertificateFilePath <path to pfx file>
-CertificatePassword <pfx password>
So you'll need those 3 pieces of information for every single certificate upload.
I'd suggest you put together a spreadsheet with those 3 columns and save it as a CSV file, eg:
"Name","CertificateFilePath","CertificatePassword"
"abc.domain.tld","C:\cert1.pfx","s3cr3tp@ssw0rd"
"def.domain.tld","C:\cert2.pfx","s3cr3tp@ssw0rd2"
...
Once you have your CSV, it's as simple as calling Import-Csv
to import the data, and then just repeat the New-AzWebAppSSLBinding
call for each row:
foreach($row in Import-Csv .\path\to\bindings.csv){
New-AzWebAppSSLBinding -WebAppName WebApiStaging -Name $row.Name -ResourceGroupName Staging -CertificateFilePath $row.CertificateFilePath -CertificatePassword $row.CertificatePassword -SslState SniEnabled
}
Upvotes: 0