I need to make requests to an API which has a certificate issued by a custom certificate authority. Currently I am uploading the public certificate for each slot in each Function App through the portal. Is it possible to automate the uploading of this certificate using the Azure CLI or PowerShell? I've seen documentation on how to upload private certificates to Azure App Services, but I haven't found anything on how to upload public certificates.
Asked
Active
Viewed 911 times
1
-
You could refer to this [issue](https://stackoverflow.com/questions/57979337/how-to-upload-private-key-certificates-pfx-public-key-certificates-cer-to/58119274#58119274). – Joey Cai Jul 30 '20 at 06:05
-
Thank you for the comment. The link looks similar to the answer posted below by Jim Xu, except the answer below also uses the newer PowerShell module. – chris Jul 30 '20 at 16:24
1 Answers
1
If you want to upload public certificate to Azure function app, we can use the Azure Rest API
For example (I use the PowerShell to call the api)
Connect-AzAccount
#get function app
$appName="testpy05"
$groupName="testpy"
$app =Get-AzWebApp -ResourceGroupName $groupName -Name $appName
#get public certificate content
$cerpath="E:\Cert\test.cer"
$cerFileBytes = get-content $cerpath -Encoding Byte
$cerblob=[System.Convert]::ToBase64String($cerFileBytes)
$properties=@{
blob =$cerblob;
publicCertificateLocation="CurrentUserMy"
}
New-AzResource -ResourceName "$($appName)/testcer" -ResourceType "Microsoft.Web/sites/publicCertificates" `
-Properties $properties -ResourceGroupName $groupName

Jim Xu
- 21,610
- 2
- 19
- 39