通过ARM模板和应用程序上载部署Azure批处理
我通过UI(门户)建立了一个Azure批处理帐户,并在一切按我希望的方式运行后导出了模板 现在,我正试图通过Visual Studio 2019部署此ARM模板,并不断出现以下错误:通过ARM模板和应用程序上载部署Azure批处理,azure,powershell,azure-batch,Azure,Powershell,Azure Batch,我通过UI(门户)建立了一个Azure批处理帐户,并在一切按我希望的方式运行后导出了模板 现在,我正试图通过Visual Studio 2019部署此ARM模板,并不断出现以下错误: The specified application package does not exist. ARM模板看起来不错,我已经与它进行了协调。我这样做是为了验证模板是否允许applicationPackages元素 导致我的问题的模板的具体部分如下: "applicationPackages":
The specified application package does not exist.
ARM模板看起来不错,我已经与它进行了协调。我这样做是为了验证模板是否允许applicationPackages元素
导致我的问题的模板的具体部分如下:
"applicationPackages": [
{
"id": "[concat(resourceId('Microsoft.Batch/batchAccounts', parameters('batchAccounts_baeast909_name')), '/applications/logparser')]",
"version": "2.2"
},
{
"id": "[concat(resourceId('Microsoft.Batch/batchAccounts', parameters('batchAccounts_baeast909_name')), '/applications/powershellscripts')]",
"version": "1.0"
}
]
我希望这会像将应用程序zip放在一个名为applications的目录中一样简单,然后再次运行所有内容。遗憾的是,事实并非如此,部署失败,出现了相同的错误
其中一条评论问我为什么要这样做。答案是,我正在Azure Data Factory V2(ADFv2)外运行一个自定义活动。自定义活动通过名为LogParser.exe的可执行文件转换Weblog,该可执行文件作为应用程序加载到批处理帐户,如下所示。我还添加了PowerShell脚本,将所有内容作为一个应用程序连接在一起
我希望有一个类似于部署Web应用程序的解决方案,详情如下:
因此,我的问题是:
能否在部署ARM模板的同时部署应用程序ZIP?
如果不能,我应该在什么时候部署它们,以及如何使该过程自动化
application.json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"configuration": {
"type": "object",
"metadata": {
"description": "Configuration for this resource"
}
},
"pools_1_password": {
"type": "SecureString"
},
"batchAccounts_baeast909_name": {
"defaultValue": "baeast909",
"type": "String"
},
"storageAccounts_storageaccount909_externalid": {
"defaultValue": "/subscriptions/subguid/resourceGroups/resourcegroup909/providers/Microsoft.Storage/storageAccounts/storageaccount909",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Batch/batchAccounts",
"apiVersion": "2017-09-01",
"name": "[parameters('batchAccounts_baeast909_name')]",
"location": "eastus2",
"tags": {
"displayname": "[parameters('configuration').displayName]",
"department": "[parameters('configuration').department]",
"group": "[parameters('configuration').group]",
"environment": "[parameters('configuration').environment]",
"primaryOwner": "[parameters('configuration').primaryOwner]",
"secondaryOwner": "[parameters('configuration').secondaryOwner]",
"version": "[parameters('configuration').version]",
"ms-resource-usage": "azure-cloud-shell"
},
"properties": {
"autoStorage": {
"storageAccountId": "[parameters('storageAccounts_storageaccount909_externalid')]"
},
"poolAllocationMode": "BatchService"
}
},
{
"type": "Microsoft.Batch/batchAccounts/pools",
"apiVersion": "2017-09-01",
"name": "[concat(parameters('batchAccounts_baeast909_name'), '/1')]",
"dependsOn": [
"[resourceId('Microsoft.Batch/batchAccounts', parameters('batchAccounts_baeast909_name'))]"
],
"properties": {
"vmSize": "STANDARD_A1",
"interNodeCommunication": "Disabled",
"maxTasksPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "microsoftwindowsserver",
"offer": "windowsserver",
"sku": "2016-datacenter",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"dataDisks": [
{
"lun": 0,
"caching": "ReadWrite",
"diskSizeGB": 100,
"storageAccountType": "Standard_LRS"
}
]
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"userAccounts": [
{
"name": "jborn",
"elevationLevel": "NonAdmin",
"password": "[parameters('pools_1_password')]"
}
],
"applicationPackages": [
{
"id": "[concat(resourceId('Microsoft.Batch/batchAccounts', parameters('batchAccounts_baeast909_name')), '/applications/logparser')]",
"version": "2.2"
},
{
"id": "[concat(resourceId('Microsoft.Batch/batchAccounts', parameters('batchAccounts_baeast909_name')), '/applications/powershellscripts')]",
"version": "1.0"
}
]
}
}
]
}
application.parameters.json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"configuration": {
"value": {
"displayName": "A Batch Account",
"department": "IT",
"group": "Development",
"environment": "dev",
"primaryOwner": "user1@fred.com",
"secondaryOwner": "user2@fred.com",
"version": "1.0"
}
},
"pools_1_password": {
"reference": {
"keyVault": {
"id": "/subscriptions/subguid/resourceGroups/rgn00119/providers/Microsoft.KeyVault/vaults/keyvault909"
},
"secretName": "azureAdmin"
}
},
"batchAccounts_jc00mdpbageu2d99_name": {
"value": "jc00mdpbageu2d99"
},
"storageAccounts_jc00mdpstgeud99_externalid": {
"value": "/subscriptions/subguid/resourceGroups/rgn00119/providers/Microsoft.Storage/storageAccounts/storageAccount909"
}
}
}
请按照以下步骤使用Visual Studio 2019下载和部署ARM模板:
- 使用VisualStudio2019部署ARM模板
- 在上述文档的步骤4中,使用空白模板而不是WebApp
- 现在从下载的zip文件粘贴内容
将内容从
复制到template.json
将内容从azuredeploy.json
复制到parameters.json
azuredeploy.parameters.json
- 现在使用
# Upload and register your archive as application package
az batch application package create \
--resource-group testrg01 \
--name test01 \
--application-id app01 \
--package-file myapp-exe.zip \
--version 1.0
# Set this version of package as default version
az batch application set \
--resource-group testrg01 \
--name test01 \
--application-id app01 \
--default-version 1.0
参考资料:
希望这有帮助 请告诉我什么是
应用程序包
?为什么要尝试使用batch account部署应用程序ZIP?这篇文章中唯一涉及如何通过模板部署应用程序包的部分是最后一个项目符号-即使是对web应用程序的部署,而不是一般的应用程序包。我尝试与Azure批处理服务一起部署的应用程序包如下:PowerShell脚本和LogParser.exe。两者都是使用Azure UI门户以ZIP方式手动上载的。您的大部分回复都详细说明了如何从门户中提取模板,我已经这样做了。“我的模板”引用了成功部署所需的应用程序包。请在问题中共享您的ARM模板添加完整的application.json和application.parameters.json。删除了PII信息,并对两者进行了手动更新,但除此之外,我正在尝试部署代码。感谢您添加所有相关信息。我编辑了我的答案,以提供更多的上下文。谢谢