通过ARM部署到Azure Web App msdeploy/zipdeploy到多个子应用程序/虚拟应用程序

v7pvogib  于 12个月前  发布在  其他
关注(0)|答案(2)|浏览(123)

我希望你能帮助我解决以下问题。
我们希望在一些子应用程序/虚拟应用程序上部署Azure Web App。然而,我们在互联网上研究的内容并不是很精确,但我怀疑这不能使用ARM完成。
我们感谢任何人提供信息,帮助我们实现目标,或者使用此技术是不可能的,或者它是Azure错误。
我们尝试将“IIS Web应用程序名称”设置为
1.“[parameters('appName')]/subapp1”
1.“/subapp1”
1.“subapp1”
1.“默认网站/子应用程序1”
我们使用扩展:

  1. MSDeploy,
  2. addOnPackages和
  3. ZipDeploy
    结果总是相同的,文件仍保留在Web应用程序的根目录中。
    这是我们正在使用的ARM模板:
{
    "$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')]"
                        }
                    }
                }
            ]
        }
    ]
}

字符串
非常感谢您的帮助提前。

daupos2t

daupos2t1#

根据您的要求,您的代码对我来说看起来很好。问题可能是由于部署资源时的"IIS Web Application Name"
您可以尝试直接在siteconfig下的Microsoft.Web/sites资源中设置虚拟应用程序路径,而不是依赖于MSDeploy扩展的"IIS Web Application Name"参数。

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

字符串
因此,在"virtualApplications"数组中显式定义虚拟应用程序可确保在部署后将文件部署到正确的位置。

  • 我在检查了以上所有内容后,在我的环境中尝试了您的代码,部署成功,如下所示。*


的数据

mcvgt66p

mcvgt66p2#

默认情况下,MSDeploy的功能是部署到单个应用程序,它不理解子应用程序的概念。为了部署到root以外的路径,您需要在站点扩展资源下添加custom deployment script属性。@Jahvani的回答,谢谢!

相关问题