How To Clone An Azure Web App
Tags: azureappservice, azure, powershell, guide
Published: 2020-11-21 23:58:50

---
title: How To Clone An Azure Web App
published: true
date: 2020-11-18 04:56:09 UTC
tags: AzureAppService,Azure,Powershell,Guide
canonical_url: https://parveensingh.com/how-to-clone-an-azure-web-app/
---

 ![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/Blog-09.png)

_This is the ninth article in the " **Getting Started with Azure App Service**" Series where I publish in-depth tutorials and walkthroughs on using Azure App Service and best practices every week. In the last article, we discussed how you can set up_ [_Easy Auth for Azure App Service_](https://parveensingh.com/easy-auth-for-azure-app-service)_._

* * *

There might be a time when you'd be using Azure App Service and think if you could make an identical copy of a web application and test it externally without affecting any production workloads. App Service clone feature is here to rescue you.

This week, we are looking at how to clone Azure App Service that you can use either for testing something on identical environment if you have a production application already, or you are simply learning what the possibilities are while using App Service. Let's dive right in!

<!--kg-card-begin: markdown-->
# Table of Content

1. [Prerequisites](#prerequisites)
2. [Cloning Web App Using Azure Portal](#cloning-web-app-using-azure-portal)
3. [Cloning Web App Between Regions using PowerShell](#cloning-web-app-between-regions-using-powershell)
  - [Cloning a Standalone Web App to New Region](#cloning-a-standalone-web-app-to-new-region)
  - [Cloning a Web App With App Slots](#cloning-a-web-app-with-app-slots)
  - [Cloning a Web App to Same Region](#cloning-a-web-app-to-same-region)
4. [Cloning Existing App Slot Only](#cloning-existing-app-slot-only)
5. [Restrictions](#restrictions)
6. [Reference](#reference)

<!--kg-card-end: markdown-->

# Prerequisites

If you decide to follow along, confirm the following pre-requisites before you begin.

- Be sure that you have the latest version of PowerShell installed. You can use Cloud Shell if you prefer to stay within the Azure Portal.
- Your app service plan should be running on at least Standard Tier to perform the clone on the application. This operation cannot be performed on the Basic/Free Tier applications.
- You need a running Web App to perform the test. Follow alone once you have a POC web application to test the following steps.

# Cloning Web App Using Azure Portal

Suppose you want to move your application from Canada Central to West US, it can be accomplished using Azure Portal or PowerShell command that will create a clone of your current application in the new region.

If you prefer to use Azure Portal instead of PowerShell for the clone, follow the steps below. It's fairly easy to perform the clone in a few clicks instead of going through PowerShell.

- Navigate to Azure Portal and your Web App resource.
- On the left side blade, choose " **Clone**" option.
- Use the following screenshot and the steps below to follow

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/07-PortalClone.png)<figcaption>Clone-GuiTrigger</figcaption>

- Fill out the name for new web application and pick a resource group where you'd like to deploy it.
- You have the option to create a new App Service Plan in either the same or different region. Create one with a name of your choice.
- Under Clone Setting, make sure you enable the feature that you'd like to clone with the application.
- You can turn ON the " **Application Insights**" optionally.

The clone should take only a few minutes and you should see new resources in your destination resource group as shown in the screenshot below.

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/08-WebAppCloneGui.png)<figcaption>Clone-GuiConfirmation</figcaption>

# Cloning Web App Between Regions using PowerShell

If you are PowerShell fan, follow the instructions below to achieve the same results as with Azure Portal.

Before you run the command, you would want to confirm your application name and the resource group it resides in. Use the following command to prepare your source information of the application and replace the value of `resourcegroupname` and `name` that matches your environment names.

```
$srcapp = Get-AzWebApp -ResourceGroupName "RGNAME" -Name "AppName"

```

Once you run this command, it will store the information about your application in a variable called `srcapp` that we can use later to use during the clone command.

Since your new app will sit in a different region, you'd need to create an App Service Plan that matches your destination region. You can use Azure Portal to do this or follow the command below to achieve the same results. I assume the destination location to be `west us`. Be sure to use Standard tier as it is the minimum plan required for cloning application..

```
New-AzAppServicePlan -Location "West US" -ResourceGroupName "DestRGName" -Name "DestAppPlanName" -Tier Standard

```

## Cloning a Standalone Web App to New Region

Next up is the step to perform the clone on the new application. Use the following commands to create a new web app using an existing application as a source app. Pay attention to the flag `SourceWebApp` as we are using that to point to the already available application.

```
$destApp = New-AzWebApp -ResourceGroupName "DestRGName" -Name "dest-webapp" -Location "West US" -AppServicePlan "DestAppPlanName" -SourceWebApp $srcApp

```

The script output should be minimal as shown in the image below:

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/02-CodeRun.png)<figcaption>PowerShell Results for Standalone App Clone</figcaption>

You should see a similar view in your account with new resources in West US.

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/01-WebAppClone-01-1.png)<figcaption>Portal View of Standalone App Clone</figcaption>

## Cloning a Web App With App Slots

If you have any slots configure for your application and would like to clone them as well along with the source app, use the following commands to achieve the desired results. We are only introducing one new flag `IncludeSourceWebAppSlots` at the end.

```
$destApp = New-AzWebApp -ResourceGroupName "DestRGName" -Name "dest-webapp" -Location "West US" -AppServicePlan "DestAppPlanName" -SourceWebApp $srcApp -IncludeSourceWebAppSlots

```

PowerShell results from the script are below:

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/03-CodeRun.png)<figcaption>PowerShell Results for App Slot Clone</figcaption>

As you can also see from the screenshot below, all the slots from the source would be available in the new region once cloned.

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/04-WebAppSlotsClone.png)<figcaption>Portal View of App Slot Clone</figcaption>

## Cloning a Web App to Same Region

The same steps can be performed to clone an application in **same region** as well. You'd still need to create a new App Service Plan and use that to host the new applications. All the steps would be similar to perform the clone as it was a different region.

# Cloning Existing App Slot Only

There can be a case where you would only want to clone an app slot to either a new application or to a new slot for many different regions. The new app can be either in same or different region than the original app.

Follow through the steps below to see how you can create a **new application** from an existing slot. The command below takes a snapshot variable that holds the information about an existing application.

```
$srcAppSlot= Get-AzWebAppSlot -ResourceGroupName "SourceRGName" -Name "SourceApp" -Slot "SourceAppSlot"

```

Once you have the source app information in a variable `srcAppSlot`, you can use that to create a new application using `SourceWebApp` flag in the `New-AzWebApp` command.

```
#Create a new App Service Plan
New-AzAppServicePlan -Location "West US" -ResourceGroupName "DestRGName" -Name "DestAppPlanName" -Tier Standard

#Create new Web App
$destApp = New-AzWebApp -ResourceGroupName "DestRGName" -Name "DestApp" -Location "West US" -AppServicePlan "DestAppPlanName" -SourceWebApp $srcAppSlot

```

Here are final PowerShell results:

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/05-CodeRun.png)<figcaption>PowerShell Results for Slot Only Clone</figcaption>

You should also notice some new resources in your destination resource group now.

![How To Clone An Azure Web App?](https://parveensingh.com/content/images/2020/11/06-WebAppSlotOnlyClone.png)<figcaption>Verification for Slot Only Clone</figcaption>

# Restrictions

- Autoscale settings are not cloned. You would have to migration your scale settings manually if you have any.
- The backup setting is tied to Web App resource which you'd need to create once the application is up and running in the new region.
- VNET settings are not cloned. However, the Outbound IP address of the application will change if application is clone to different scale unit.
- App Insights would have to be configured with the new web app as they don't migrate with the clone.
- Easy Auth settings and Kudu Extension are not cloned.
- Database content is not cloned to new application.
- Unfortunately, you can only clone Windows App as of now.

# Reference

- [Clone app with PowerShell](https://docs.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning)
- [App Service Environment](https://docs.microsoft.com/en-us/azure/app-service/environment/intro)

* * *

**If it's your first time here, please check out other articles in the series:**

Part 1: [Up and Running with Azure App Service](https://parveensingh.com/up-and-running-with-azure-app-service/)

Part 2: [Continuous Deployment for Azure App Service](https://parveensingh.com/azure-app-service-continuous-integration-github-azure-repos/)

Part 3: [Using Deployment Slots with Azure App Service](https://parveensingh.com/using-deployment-slots-with-azure-app-service/)

Part 4: [Setup Custom Domain for Azure App Service](https://parveensingh.com/custom-domain-azure-app-service/)

Part 5: [Deploying Next.JS App on Azure App Service](https://parveensingh.com/next-js-deployment-on-azure-app-service)

Part 6: [Next.JS App with Cosmos DB on Azure App Service](https://parveensingh.com/next-js-node-app-with-cosmos-db/)

Part 7: [Why Should You Use Azure App Service?](https://parveensingh.com/why-should-you-use-azure-app-service/)

Part 8: [Easy Auth for Azure App Service](https://parveensingh.com/easy-auth-for-azure-app-service)

**Part 9: [How To Clone An Azure Web App?](https://parveensingh.com/how-to-clone-an-azure-web-app)**