Normally you wouldn’t need to remove the App Service Resource Provider on one of your Azure Stack stamps. However, in this case, we had installed the resource provider using a single file server and a single SQL server and needed to redeploy using a highly available solution. I looked over the Microsoft documentation and couldn’t find anything on how to uninstall the App Service Resource provider. I also did a decent search using Bing and Google and didn’t find anything on how to remove the resource provider. So, I did the next best thing. I started to poke around and look through some of the files provided with the installer and in the Azure Stack Tools on Github as well.
I did find a PowerShell script called Remove-AppService within the App Service Helper Scripts directory. So I took a shot in the dark and tried it. Heck, why not right? I noticed that there are four parameters that it was going to require $ResourceGroupName, $DirectoryTenantName, $AdminArmEndPoint, and the $AzureStackAdminCredential. So like any responsible person I gave the script those parameters and the script started to run. However, all it would do was repeat a status message over and over again for about 30 seconds before it would fail. I tried it a few times, took a look at the Activity Logs, even went over to the resource provider manifest where the resource it was trying to remove is listed. However, the provision state never changed, and that resource provider was never removed.
So long story short I opened a ticket with Microsoft after talking to Andrew Westgarth. It was explained that there was a process in place and that they could walk me through. So I opened the ticket, and very soon got a call back from someone who I have worked with a few times already. Very smart guy out of North Carolina, in fact, everyone that I have worked with troubleshooting small issues here and there on Stack has been outstanding.
There was only a two-step process to remove the App Service Resource Provider. In fact, it took a lot less time than you had to waste reading this blog. The main reason you need to call support is for a SQL script that will clean up the App Service objects like the databases and the logins.
So two very easy steps and you no longer have the App Service Resource Provider on your Azure Stack stamp. This will work for the ASDK as far as I know as well. So if you want to test deployment of the App Service RP over and over in your ASDK environment this would be a good way to do it.
Removing App Service Resouce Provider
First, find the resource group that you deployed your App Service RP into. For this example, we will use the default App Service Resource Group called AppService.dfw. In the ASDK it would most likely be called AppService.local. Here is how hard this is, click on that resource group, then click on the “Delete resource group” option.
Second, run the SQL script that is provided by Microsoft to remove the two App Service databases and the logins from the SQL host.
In my case, I have deployed everything into the same resource group and didn’t care about the file server and the SQL server so all I had to do was delete the resource group. At this point, you are free to reinstall the App Service RP if you need.
Final Thoughts
Overall this was fairly an easy process once I figured out how to do it. To be honest it is a little scary that you can remove something this vital so easy and fast. I would suggest a few things here. The first, make sure you are backing up this solution just in case someone does this on accident or out of spite. Next, look into locking these resources using the lock feature. I personally haven’t tried this yet but once we move to production with this new stamp I am thinking about doing this to all resource critical objects.