In the last couple of weeks I’ve had to copy a bunch of Azure WebApps and Functions from one Azure Tenant to another. I hadn’t had to do this for a while and went looking for the quickest and easiest way to accomplish it. As with anything cloud based, things move fast. Some of the methods I found were too onerous and more complex than they needed to be. There is of course the Backup option as well. However for WebApps that is only available if you are on a Standard or above tier Plan. Mine weren’t and I didn’t have the desire to uplift to get that feature.
In this post I show my method to quickly copy an Azure WebApp from one Azure Tenant to another. I cover copying Azure Functions in another post. My approach is;
- In the Source Tenant from the WebApp
- Download the Automation Scripts for the WebApp
- Using Kudu take a backup of the wwwroot folder
- In the Target Tenant
- Create a new Resource from a Template
- Import the Deployment Automation Scripts from above
- Modify for any changes, Resource Group, Location etc
- Use Zip Push Deploy to upload the wwwroot archive and deploy it
Backing up the WebApp in the Source Tenant
Open your WebApp in the Azure Portal. Select Automation Script
Download the Automation Script
Select Advanced Tools
Select the Site Folder then on the right menu of wwwroot select the download icon and save the backup of the WebApp.
Expand the Deployment Script archive file from the first step above. The contents will look like those below.
Deploy the WebApp to another Tenant
In the Azure Portal select Create a Resource from the top of the menu list on the left hand side. Type Template in the search box and select Template Deployment then select Create. Select Build your own template in the editor. Select Load File and select the parameters.json file. Then select Load File again and select the template.json file. Select Save.
Make any changes to naming, and provide an existing or new Resource Group for the WebApp. Select Purchase.
The WebApp will be created. Once completed select it from the Resource Group you specified and select Advanced Tools. From the Tools menu select Azure Zip Push Deploy.
Drag and drop the Azure Zip Push Deploy zip file with the archive of the wwwroot folder you created earlier.
The Azure Zip Push Deploy zip file will be processed and the WebApp deployed.
Selecting the App in the new Tenant we can see it is deployed and running.
Hitting the App URL we can see that is being served.
This WebApp is the Microsoft Identity Manager User Object Report that I detailed in this post here.
In less that 10 minutes the WebApp is copied. No modifying JSON files, no long command lines, no FTP clients. Pretty simple. In the next post I’ll detail how I copied Azure Functions using a similar process.
Keep in mind if your WebApp is using Application Settings, KeyVaults, Managed Service Identity type options you’ll need to add those settings, certificates/credentials in the target environment.