當我嘗試使用 ARM 模板創建搜索服務時,它顯示以下錯誤
無法決議相對路徑“artifacts/linkedTemplate.json”。請確保父部署參考外部 URI 或模板規范 ID。使用本地檔案創建模板部署時,不能使用 relativePath 屬性。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"searchService_name": {
"type": "string"
}
},
"variables": {
"linked-template": "artifacts/azure_deploycopy.json"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"name": "azure-restore",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "[variables('linked-template')]"
},
"parameters": {
"searchService_name": {
"value": "[parameters('searchService_name')]"
}
}
}
}
],
"outputs": {}
}
uj5u.com熱心網友回復:
您能否添加有關部署的更多詳細資訊?
- 您是否使用 PS、AZCLI 進行部署,是否設定了作業檔案夾?
- 鏈接模板位于何處 - 本地或作為模板規范
- 帶有鏈接模板的檔案夾結構
@NithinViswanathan 根據您的評論,我想出了為什么它對您不起作用以及如何繼續前進。正如在另一個答案中一樣 - Azure 資源管理器 (ARM) 不知道您的本地依賴項。要使這種復雜的部署作業,您需要首先創建模板規范。模板規范將包含您的主模板,并將包括依賴檔案夾和/或模板。
為此,請從創建模板規范開始:
az ts create --name <name_of _tempsepc> -g <destination_resourcegroup> -f <main template path ie. ./maintemplate.json> -v <template version ie. 1.0.0> --version-description "init template specs" -l <location ie. westeurope>
這將創建如下資源:
模板規格圖片
找到模板規范 ID 并部署它:
id = $(az ts show --name <template_spec_name> --resource-group <template spec rg> --version "1.0.0.0" --query "id")
az deployment group create \
--resource-group <target rg> \
--template-spec $id
uj5u.com熱心網友回復:
在 Azure 中使用嵌套/鏈接模板時,您需要使用 Azure 在部署模板時可以訪問的 URI。這意味著它不應該是本地的,除非通過 azure cloud shell 部署。
MS Learn 有很多關于 arm 模板和鏈接模板的好資訊。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/520501.html
