You can now use this action in Azure Resource Manager mode of the Azure Powershell library. This also assumes that the selected certficate is already available in Azure, I already had the certificate used on other sites, so I did not need to upload it before adding it to the new site.
Install the library first to use Azure Resource Manager mode. This article provides a good idea of ββwhat this mode provides.
Switch-AzureMode -Name AzureResourceManager Add-AzureAccount Select-AzureSubscription -SubscriptionId $subscriptionId
The following variables are used in the code below:
$apiVersion = "2015-08-01" $subscriptionId = "" #The ID of your Azure subscription $siteName = "myWebApp" $resGroup = "myResourceGroup" $appServicePlan = "myAppServicePlan" $location = "East US" #Select the appropriate Azure data centre. $hostName = "mywebapp.mydomain.com" $sslThumbprint = "" # Thumbprint of SSL certificate uploaded for use in Azure.
Once the correct mode is selected, the following code will retrieve the current site information. The new SSL information can then be added to the new object, which can be added to the end of the current HostNameSslStates array.
Finally, you can drop it back into Azure using the Set-AzureResource cmdlet.
# Add SSL binding to custom domain $r = Get-AzureResource -Name $siteName -ResourceGroupName $resGroup -ResourceType Microsoft.Web/sites -ApiVersion $apiVersion -OutputObjectFormat New
MartynJones87
source share