How can I clone or copy an Azure Function App (Hosting set to App Service Plan) from one Azure account to another?
I'm completely new to Azure functions and have no experience working with this, but I have a simple request to clone/copy an Azure Function App (Hosting set to App Service Plan) from one Azure account to another azure account. How to achieve this?
Azure Functions
-
Ranashekar Guda • 2,430 Reputation points • Microsoft External Staff • Moderator
2025-06-10T19:10:14.8766667+00:00 Hello @Vivek Komarla Bhaskar,
To clone or copy an Azure Function App hosted on an App Service Plan from one Azure account to another, you can follow a straightforward process. First, export the configuration settings from your existing Function App, including app settings and connection strings. This can be done easily using the Azure CLI with commands likeaz functionapp config appsettings list
to export the settings into a JSON file.Next, log in to your target Azure account and create a new Function App with the same runtime stack, region, and App Service Plan tier to match your source environment. After creating the new Function App, import the previously exported configuration settings using Azure CLI commands such as
az functionapp config appsettings set
. Once the configuration is in place, deploy your function code to the new app. You can do this by using zip deployment with Azure CLI, integrating with source control systems like GitHub Actions or Azure DevOps, or publishing directly from development tools like Visual Studio or VS Code.Finally, thoroughly test the new Function App to ensure that all triggers, bindings, and integrations are functioning correctly. If you prefer an infrastructure-as-code approach, you can also export your Function App as an ARM template from the Azure portal and deploy it to the new account to automate the process. This step-by-step method ensures a smooth and reliable migration of your Azure Function App between accounts.
Hope this helps. Do let us know if you any further queries.
-
SUNOJ KUMAR YELURU • 15,251 Reputation points • MVP • Volunteer Moderator
2025-06-11T05:38:13.7333333+00:00 Hello @Vivek Komarla Bhaskar
The Azure Function App can be cloned or copied from one Azure account to another by exporting it as an ARM template from the source account and then deploying that template to the target Azure account. Careful consideration must be given to parameterizing or updating connection strings, application settings, source control configuration, and managed identities.
[Step 1]: Export the ARM Template from the Source Azure Account
- Using the Azure Portal:
* Navigate to the Function App in the Azure portal.
* In the left-hand menu, under "Automation", select "Export template".
* Click "Download" to download the ARM template as a ZIP file. The ZIP file contains the template file (template.json), a parameters file (parameters.json), and potentially other related files.
- Using Azure CLI:
* Log in to the Azure account containing the Function App:
az login
* Set the correct subscription:
az account set --subscription "<Subscription ID or Name>"
* Export the ARM template:
az resource export --resource-group "<Resource Group Name>" --name "<Function App Name>" --resource-type "Microsoft.Web/sites" --output-file template.json
* If you want to include parameters, you can use:
az resource export --resource-group "<Resource Group Name>" --name "<Function App Name>" --resource-type "Microsoft.Web/sites" --include-parameter-default-value --output-file template.json
[Step 2]: Review and Modify the ARM Template
- Unzip the downloaded ZIP file (if you used the portal).
- Open
template.json
andparameters.json
in a text editor. - Review the template:
* Ensure that all necessary resources are included (Function App, App Service Plan, Storage Account, Application Insights, etc.).
* Pay close attention to resource dependencies.
- Modify
parameters.json
(ortemplate.json
if you prefer to hardcode values):
* Update the
defaultValue
for parameters likename
(Function App name),___location
, and any other environment-specific settings. Consider making these parameters required if they must be specified during deployment.Important: Handle connection strings and application settings. The exported template might contain sensitive information. You can either parameterize these values or update them after deployment. Parameterizing is generally preferred. For example:
```json
// In parameters.json
{
"parameters": {
"storageAccountConnectionString": {
"type": "string",
"metadata": {
"description": "The connection string for the storage account."
}
}
}
}
// In template.json (within the Function App resource definition)
{
"type": "Microsoft.Web/sites/config",
"name": "[concat(parameters('name'), '/appsettings')]",
"apiVersion": "2022-03-01",
"properties": {
"AzureWebJobsStorage": "[parameters('storageAccountConnectionString')]"
}
}
```
- App Service Plan Considerations:
* The ARM template will include the App Service Plan definition. Ensure that the
sku
(size and tier) of the App Service Plan is appropriate for the target environment and that the target Azure account has sufficient quota. You might need to create the App Service Plan separately in the target account if quota is an issue. If you create it separately, you'll need to modify the ARM template to use the existing App Service Plan instead of creating a new one.[Step 3]: Deploy the ARM Template to the Target Azure Account
- Log in to the Target Azure Account:
az login
- Set the correct subscription:
az account set --subscription "<Target Subscription ID or Name>"
- Create a new resource group (recommended):
az group create --name "<New Resource Group Name>" --___location "<Location>"
- Deploy the ARM template:
Using Azure CLI:
```bash
az deployment group create \
--resource-group "<New Resource Group Name>" \
--template-file template.json \
--parameters parameters.json \
--parameters storageAccountConnectionString="<Your Storage Account Connection String>"
```
Replace
<Your Storage Account Connection String>
with the actual connection string value, or any other parameters you defined.Using the Azure Portal:
* Search for "Deploy a custom template" in the Azure portal.
* Click "Build your own template in the editor".
* Load the
template.json
file.* Save the template.
* Fill in the required parameters and click "Review + create".
* Click "Create".
[Step 4]: Configure Application Settings and Connection Strings (if not parameterized)
- Navigate to the Deployed Function App in the Target Azure Account.
- Go to "Configuration" under "Settings".
- Update Application Settings and Connection Strings:
* Add or modify any application settings or connection strings that were not parameterized in the ARM template. This is crucial for the Function App to function correctly in the new environment.
[Step 5]: Configure Source Control (if applicable)
- Navigate to the Deployed Function App in the Target Azure Account.
- Go to "Deployment Center" under "Deployment".
- Configure Source Control:
* Set up the connection to your source control repository (e.g., GitHub, Azure DevOps).
* Configure the deployment settings.
[Step 6]: Configure Managed Identities (if applicable)
- Navigate to the Deployed Function App in the Target Azure Account.
- Go to "Identity" under "Settings".
- Enable System assigned or User assigned Managed Identity.
- Grant Permissions:
* Grant the necessary permissions to the Managed Identity to access other Azure resources (e.g., Key Vault, Storage Account). This typically involves assigning roles to the Managed Identity in the Azure portal or using Azure CLI.
[Step 7]: Test the Function App
- Test all Function App endpoints to ensure they are working correctly.
- Monitor the Function App logs for any errors.
If this answers your query, do click
Accept Answer
and Up-Vote for the same. And, if you have any further query do let us know. -
Ranashekar Guda • 2,430 Reputation points • Microsoft External Staff • Moderator
2025-06-12T01:12:43.3633333+00:00 Hello @Vivek Komarla Bhaskar,
Just checking in to see if information was helpful. If you have any further updates on this issue, please feel free to post back. -
Vivek Komarla Bhaskar • 956 Reputation points
2025-06-12T08:01:51.07+00:00 Hi @SUNOJ KUMAR YELURU
I’ve tried this approach several times but continue to encounter an internal server error. I’ve updated the parameter settings to reflect the new account, but the error persists. -
Ranashekar Guda • 2,430 Reputation points • Microsoft External Staff • Moderator
2025-06-12T16:52:58.7733333+00:00 Hello @SUNOJ KUMAR YELURU,
Could you please share your suggestions on @Vivek Komarla Bhaskar queries?
-
Ranashekar Guda • 2,430 Reputation points • Microsoft External Staff • Moderator
2025-06-13T19:35:53.6133333+00:00 Hello @Vivek Komarla Bhaskar,
Sorry to hear you're facing issues. An internal server error during deployment often points to problems in the ARM template or parameter values. Please ensure all settings like app names, storage account names, and connection strings are correct and valid for the target Azure account. Also, make sure resource names (especially storage accounts) are globally unique. You can runaz deployment group validate
to check the template before deploying, and add--debug
for more detailed error info. Additionally, check the “Deployments” section in your target resource group on the Azure portal to view detailed error logs.
Sign in to comment