skip to Main Content

I hope you can help me with the following situation.

We want to deploy an Azure Web App on some sub-applications / virtual-applications. However, what We have researched on the internet has not been very precise with the technique required for this, but I doubt that it cannot be done using ARM.

We appreciate if anyone has information that leads us to achieve the objective or if it is impossible using this technique or it is an Azure bug.

We have tried setting the "IIS Web Application Name" to

  1. "[parameters(‘appName’)]/subapp1"
  2. "/subapp1"
  3. "subapp1"
  4. "Default Web Site/subapp1"

We have used extensions:

  1. MSDeploy,
  2. addOnPackages and
  3. ZipDeploy

And the result is always the same, the files remain on the root of the web application.

This is the ARM template that we are using:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string",
            "metadata": {
                "description": "Location of resources"
            },
            "defaultValue": "[resourceGroup().location]"
        },
        "_artifactsLocation": {
            "type": "string",
            "metadata": {
                "description": "The base URI where artifacts required by this template are located including a trailing '/'"
            },
            "defaultValue": "[deployment().properties.templateLink.uri]"
        },
        "_artifactsLocationSasToken": {
            "type": "securestring",
            "metadata": {
                "description": "The sasToken required to access _artifactsLocation.  When the template is deployed using the accompanying scripts, a sasToken will be automatically generated. Use the defaultValue if the staging location is not secured."
            },
            "defaultValue": ""
        },
        "appName": {
            "type": "string",
            "metadata": {
                "description": "App Name"
            },
            "defaultValue": "testapp123"
        }
    },
    "variables": {
        "existingPlanAppServiceName": "[concat('PlanAppService-',uniqueString(resourceGroup().id))]"
    },
    "resources": [
        {
            "apiVersion": "2022-03-01",
            "name": "[variables('existingPlanAppServiceName')]",
            "type": "Microsoft.Web/serverfarms",
            "location": "[parameters('location')]",
            "kind": "",
            "tags": {},
            "dependsOn": [],
            "properties": {
                "name": "[variables('existingPlanAppServiceName')]",
                "workerSize": "18",
                "workerSizeId": "18",
                "numberOfWorkers": "1",
                "zoneRedundant": false
            },
            "sku": {
                "Tier": "Premium0V3",
                "Name": "P0V3"
            }
        },
        {
            "apiVersion": "2022-03-01",
            "name": "[parameters('appName')]",
            "type": "Microsoft.Web/sites",
            "location": "[parameters('location')]",
            "tags": {},
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', variables('existingPlanAppServiceName'))]"
            ],
            "properties": {
                "name": "[parameters('appName')]",
                "siteConfig": {
                    "metadata": [
                        {
                            "name": "CURRENT_STACK",
                            "value": "dotnet"
                        }
                    ],
                    "virtualApplications": [
                        {
                            "virtualPath": "/",
                            "physicalPath": "site\wwwroot",
                            "preloadEnabled": false
                        },
                        {
                            "virtualPath": "/subapp1",
                            "physicalPath": "site\wwwroot\subapp1",
                            "preloadEnabled": true
                        }
                    ],
                    "phpVersion": "OFF",
                    "netFrameworkVersion": "v4.0",
                    "alwaysOn": true,
                    "ftpsState": "Disabled",
                    "use32BitWorkerProcess": false,
                    "http20Enabled": true,
                    "websiteTimeZone": "SA Pacific Standard Time"
                },
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('existingPlanAppServiceName'))]",
                "clientAffinityEnabled": false,
                "httpsOnly": true,
                "publicNetworkAccess": "Enabled"
            },
            "resources": [
                {
                    "type": "Microsoft.Web/sites/extensions",
                    "apiVersion": "2022-03-01",
                    "name": "[concat(parameters('appName'), '/MSDeploy')]",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/sites', parameters('appName'))]"
                    ],
                    "properties": {
                        "packageUri": "[uri(concat(parameters('_artifactsLocation'),'filesApp.zip'),parameters('_artifactsLocationSasToken'))]",
                        "dbType": "None",
                        "connectionString": "",
                        "appOffline": true,
                        "setParameters": {
                            "IIS Web Application Name": "[concat(parameters('appName'),'/subapp1')]"
                        }
                    }
                }
            ]
        }
    ]
}

Thank you very much for your help in advance.

2

Answers


  1. Chosen as BEST ANSWER

    By default the functionality of MSDeploy is to deploy to a single application and it doesn't understand the concept of sub applications. In order to deploy into the path other than root, you need to add a custom deployment script property under a site extension resource. Answer of @Jahvani, Thanks!


  2. Your code looks good for me according to your requirement. The issue might be due to the "IIS Web Application Name" while deploying the resource.

    Rather than depending on the MSDeploy extension’s "IIS Web Application Name" argument, you can try setting the virtual application path directly in the Microsoft.Web/sites resource under siteconfig.

    "siteConfig":  { 
      "virtualApplications":  [  
          { 
       "virtualPath":  "/add your requirement of virtual path here", 
       "physicalPath":  "site\wwwroot\xxxappexample", 
        "preloadEnabled":  true
          } 
       ], 
      }
    

    So, defining the virtual application explicitly in the "virtualApplications" array ensure that the files are deployed to the correct location after deployment.

    I tried your code in my environment after checking all the above and the deployment was successful as shown below.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search