As mentioned in this post yesterday I needed to copy a bunch of Azure WebApps and Functions from one Tenant to another. 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 for Azure Functions. This does require a storage account associated with the Function App Plan. My Functions didn’t have the need for storage and the plan tier they were on meant that wasn’t a prerequisite. I didn’t have the desire to add a storage account to backup to then migrate.
In this post I show my method to quickly copy Azure Functions from one Azure Tenant to another. My approach is;
- In the Source Tenant from the Azure Functions App
- Using Kudu take a backup of the wwwroot folder (that will contain one or more Functions)
- In the Target Tenant
- Create an Azure Function App
- Using Kudu locate the wwwroot archive in the new Azure Function App
- Configure Azure Function Run From Zip
Backing up the Azure Functions in the Source Tenant
Using the Azure Portal in the Source Tenant go to your Function App => Application Settings and select Advanced Tools. Select Debug Console – Powershell and navigate to the Site Folder. Next to wwwroot select the download icon to obtain an archive of your functions.
Copying the Azure Functions to the Target Tenant
In the Target Tenant first create a New Azure Function App. I did this as I wanted to change the naming, the plan and a few other configuration items. Then using the Azure Portal go to your new Function App, Application Settings and select Advanced Tools.
Create a folder under D:\home\data named SitePackages.
Drag and drop your wwwroot.zip file into the SitePackages Folder.
In the same folder select the + icon to create a file named siteversion.txt
Inside the file give the name of your archive file e.g. wwwroot.zip Select Save.
Back in your new Function App select Application Settings
Under Application Settings add a new setting for Website_Use_Zip with a setting value of ‘1’.
Refresh your Function App and you’ll notice it is now Read Only as it is running from Zip. All the Functions that were in the Zip are displayed.
This is a quick and easy method to get your functions copied from one Tenant to another. Keep in mind if your functions are using Application Settings, KeyVaults, Managed Service Identity type options you’ll need to add those settings, certificates, credentials in the target environment.