How to add an Azure App Service extension via powershell?
Our continuous integration framework automatically deploys a new Azure App Service for each deployment. So this means that it removes the old intermediate segment and recreates it before going into production. This way we get a fresh start and all new configurations and services are deployed.
This has been good so far, we also need a useful extension of the site. When we install this extension manually, it will just get lost when we do a new deployment again.
How do I install a site extension in Azure App Service via powershell? My CI process can do this easily.
+3
source to share
1 answer
You can check this example .
### Install NewRelic Extension for Azure App###
write-output "*** Installing New Relic on PROD Site"
$WebSite = "your site name"
$Kudu = "https://" + $WebSite + ".scm.azurewebsites.net/api/extensionfeed" # Here you can get a list for all Extensions available.
$InstallNRURI = "https://" + $WebSite + ".scm.azurewebsites.net/api/siteextensions" # Install API EndPoint
$username = "`$UserName"
$password = "hxWN9sjrqt9haA3NpG1kTK0QBui2ph7cEGQlcMQhYTiWqDWL9yf1aXGIJHTD"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$invoke = Invoke-RestMethod -Uri $Kudu -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method get ###-InFile $filePath -ContentType "multipart/form-data"
$id = ($invoke | ? {$_.id -match "NewRelic*"}).id ### Searching for NewRelic ID Extension
try {
$InstallNewRelic = Invoke-RestMethod -Uri "$InstallNRURI/$id" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method Put
$Status = ($InstallNewRelic.provisioningState).ToString() + "|" + ($InstallNewRelic.installed_date_time).ToString() ### Status
Write-Output "NewRelic Installation Status : $Status"
Restart-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $WebSite -Verbose ### Restarting the WebApp
}
catch{$_}
+2
source to share