我希望您能帮助我解决以下情况。
我们想在一些子应用程序/虚拟应用程序上部署Azure Web App。然而,我们在互联网上研究的内容对于所需的技术并不是非常精确,但我怀疑使用 ARM 无法完成。
如果有人提供可以引导我们实现目标的信息,或者无法使用此技术或者这是 Azure 错误,我们将不胜感激。
我们尝试将“IIS Web 应用程序名称”设置为
我们使用了扩展:
结果始终相同,文件保留在 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')]"
}
}
}
]
}
]
}
非常感谢您提前提供的帮助。
根据您的要求,您的代码对我来说看起来不错。该问题可能是由于部署资源时的
"IIS Web Application Name"
造成的。
您可以尝试直接在
MSDeploy
下的 "IIS Web Application Name"
资源中设置虚拟应用程序路径,而不是依赖于 Microsoft.Web/sites
扩展的 siteconfig
参数。
"siteConfig": {
"virtualApplications": [
{
"virtualPath": "/add your requirement of virtual path here",
"physicalPath": "site\\wwwroot\\xxxappexample",
"preloadEnabled": true
}
],
}
因此,在
"virtualApplications"
数组中显式定义虚拟应用程序可确保部署后将文件部署到正确的位置。
检查完上述所有内容后,我在我的环境中尝试了您的代码,部署成功,如下所示。