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.

Overview

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.
Download WWWRoot Folder 2.PNG

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.
Function Advanced Tools
Create a folder under D:\home\data named SitePackages.
Create Site Packages Folder
Drag and drop your wwwroot.zip file into the SitePackages Folder.
Drag Drop wwwroot
In the same folder select the + icon to create a file named siteversion.txt
Site Packages
Inside the file give the name of your archive file e.g.  wwwroot.zip Select Save.
Siteversion.txt.png
Back in your new Function App select Application Settings
Application Settings
Under Application Settings add a new setting for Website_Use_Zip with a setting value of ‘1’.
Website Use Zip.PNG
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.
Functions Migrated.PNG

Summary

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.

Category:
Application Development and Integration
Tags:
,

Join the conversation! 3 Comments

  1. Hi, I have a basic question on Azure function. Each Azure function will be deployed as individual webapp internally?
    For example, if I have 100 Azure Functions then, Azure internally will create 100 Web Apps?

Comments are closed.