Install Azure Web App Extension using PowerShell

Our company has been using Cloud Services (classic) for some time now and I was tasked with migrating our application to Azure Web Apps. Our company used a MSI to install the New Relic agent as part of the Cloud Services startup. When we switched to Web Apps, I setup our Azure Web Apps to install the New Relic extension. What I did not know at the time was the fact that when you create a staging slot using the PowerShell command New-AzWebAppSlot, extensions are not carried over.

I had to devise a way for our deployment process to be able to create a new staging slot and still be able to install New Relic before swapping slots. Turns out, this is not documented very well by Microsoft or anyone really at the time of writing this.

Below are the methods I use to install new relic (or any extension) on an Azure Web app. If you are trying to install New Relic – the extension name is “NewRelic.Azure.WebSites.Extension”. If you are looking for the name of another extension, I have provided instructions on how to get that name below.

New-AzResource -ResourceType "Microsoft.Web/sites/siteextensions" -ResourceGroupName RGNAME -ResourceName "WEBAPPNAME/EXTENSIONNAME" -ApiVersion '2018-02-01' -Force

If you are trying to install the extension on a slot (such as a staging slot), use this command. I could not find a way to deploy to the production slot/staging slot using the same command. If you can find a way, please let me know in the comment section!

New-AzResource -ResourceType "Microsoft.Web/sites/slots/siteextensions" -ResourceGroupName RGNAME -ResourceName "WEBAPPNAME/SLOTNAME/EXTENSIONNAME" -ApiVersion '2018-02-01' -Force

Find extension name

To find the extension name, we will use Kudo to get that!

  1. Open the Azure Portal and navigate to your Web App
  2. In the sidebar, click Advanced Tools and click Go. This should open a new Tab to the Kudo interface.
  3. You should see a heading called REST API. Under there, you will find Site Extensions: installed | feed
  4. If you have the app installed on this web ap, you can click installed and you will see the information for just what you have installed. If you do not have it installed, you can click feed and see all the installable extensions that the Azure Portal lets you install.
  5. You should now see JSON data for the extensions. Find your extension and look for its id. The ID is what you need to put into the above PowerShell command (without the extra quotes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: