Azure ARM 템플릿 - VM용 여러 Microsoft.Compute/virtualMachines/확장

Azure ARM 템플릿 - VM용 여러 Microsoft.Compute/virtualMachines/확장

프로비전된 경우 bacpac을 Azure mssql VM으로 자동 복원하려고 하는데 사용자 지정 스크립트 확장을 사용하면 실패합니다. 포털에서 자동화 스크립트를 사용하여 Azure MSSSQL VM ARM 템플릿을 생성했는데 이 내용을 자세히 보면 VM 포스트 프로비저닝에서 mssql을 설정하기 위해 이미 사용자 지정 확장을 사용하고 있는 것을 알 수 있습니다. 프로비저닝 후 그 위에 DB를 복원해야 하는 경우 다른 사용자 정의 스크립트 확장 리소스가 필요합니다. 나는 다른 방법을 생각할 수 없습니다. 하지만 무엇을 시도해도 두 번째 사용자 정의 스크립트 확장인 'DependsOn' 태그에서 구문 오류가 계속 발생합니다. 이 작업을 수행하는 데 도움을 주시면 감사하겠습니다. DidonsOn에서 다양한 방법으로 리소스 이름을 추가하려고 시도했지만 계속 오류가 발생합니다.

"message": "배포 템플릿 유효성 검사에 실패했습니다. '1' 줄과 '7717' 열의 템플릿 리소스 'dbrestore'가 유효하지 않습니다. 리소스 식별자 'bugtvm/SqlIaasExtension'의 형식이 잘못되었습니다.https://aka.ms/arm-template-expressions/#reference자세한 사용법은.. 참조하세요https://aka.ms/arm-template-expressions자세한 사용법은.'.", "target": null

감사해요

{
  "name": "[parameters('virtualMachineName')]",
  "type": "Microsoft.Compute/virtualMachines",
  "apiVersion": "2016-04-30-preview",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]",
    "[concat('Microsoft.Storage/storageAccounts/', parameters('diagnosticsStorageAccountName'))]"
  ],
  "properties": {
    "osProfile": {
      "computerName": "[parameters('virtualMachineName')]",
      "adminUsername": "[parameters('adminUsername')]",
      "adminPassword": "[parameters('adminPassword')]",
      "windowsConfiguration": {
        "provisionVmAgent": "true"
      }
    },
    "hardwareProfile": {
      "vmSize": "[parameters('virtualMachineSize')]"
    },
    "storageProfile": {
      "imageReference": {
        "publisher": "MicrosoftSQLServer",
        "offer": "SQL2016SP1-WS2016",
        "sku": "Web",
        "version": "latest"
      },
      "osDisk": {
        "createOption": "fromImage",
        "managedDisk": {
          "storageAccountType": "Standard_LRS"
        }
      },
      "dataDisks": [
        {
          "createOption": "empty",
          "lun": 0,
          "diskSizeGB": "128",
          "caching": "ReadOnly",
          "managedDisk": {
            "storageAccountType": "Standard_LRS"
          }
        }
      ]
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
        }
      ]
    },
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": true,
        "storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', parameters('diagnosticsStorageAccountName')), '2015-06-15').primaryEndpoints['blob']]"
      }
    }
  }
},
{
  "apiVersion": "2015-06-15",
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(parameters('virtualMachineName'), '/SqlIaasExtension')]",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
  ],
  "properties": {
    "type": "SqlIaaSAgent",
    "publisher": "Microsoft.SqlServer.Management",
    "typeHandlerVersion": "1.2",
    "autoUpgradeMinorVersion": "true",
    "settings": {
      "AutoTelemetrySettings": {
        "Region": "[parameters('location')]"
      },
      "AutoPatchingSettings": {
        "PatchCategory": "WindowsMandatoryUpdates",
        "Enable": true,
        "DayOfWeek": "[parameters('sqlAutopatchingDayOfWeek')]",
        "MaintenanceWindowStartingHour": "[parameters('sqlAutopatchingStartHour')]",
        "MaintenanceWindowDuration": "[parameters('sqlAutopatchingWindowDuration')]"
      },
      "AutoBackupSettings": {
        "Enable": true,
        "RetentionPeriod": "[parameters('sqlAutobackupRetentionPeriod')]",
        "EnableEncryption": false
      },
      "KeyVaultCredentialSettings": {
        "Enable": false,
        "CredentialName": ""
      },
      "ServerConfigurationsManagementSettings": {
        "SQLConnectivityUpdateSettings": {
          "ConnectivityType": "[parameters('sqlConnectivityType')]",
          "Port": "[parameters('sqlPortNumber')]"
        },
        "SQLWorkloadTypeUpdateSettings": {
          "SQLWorkloadType": "[parameters('sqlStorageWorkloadType')]"
        },
        "SQLStorageUpdateSettings": {
          "DiskCount": "[parameters('sqlStorageDisksCount')]",
          "NumberOfColumns": "[parameters('sqlStorageDisksCount')]",
          "StartingDeviceID": "[parameters('sqlStorageStartingDeviceId')]",
          "DiskConfigurationType": "[parameters('sqlStorageDisksConfigurationType')]"
        },
        "AdditionalFeaturesServerConfigurations": {
          "IsRServicesEnabled": "[parameters('rServicesEnabled')]"
        }
      }
    },
    "protectedSettings": {
      "StorageUrl": "[reference(resourceId('Microsoft.Storage/storageAccounts', parameters('diagnosticsStorageAccountName')), '2015-06-15').primaryEndpoints['blob']]",
      "StorageAccessKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('diagnosticsStorageAccountName')), '2015-06-15').key1]",
      "SQLAuthUpdateUserName": "[parameters('sqlAuthenticationLogin')]",
      "SQLAuthUpdatePassword": "[parameters('sqlAuthenticationPassword')]"
    }
  }
},
{
  "apiVersion": "2015-06-15",
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "dbrestore",
  "location": "[resourceGroup().location]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName') )]",
    "[concat(parameters('virtualMachineName'),'/', 'SqlIaasExtension')]"
  ],
  "properties": {
    "publisher": "Microsoft.Compute",
    "type": "CustomScriptExtension",
    "typeHandlerVersion": "1.9",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "fileUris": [
        "https://somestoragehere.blob.core.windows.net/dbbackups/restorescript.ps1"
      ]
    },
    "protectedSettings": {
      "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File restorescript.ps1",
      "storageAccountName": "some storage here",
      "storageAccountKey": "some key here"
    }
  }
},

답변1

근본적인 이유는 "[concat(parameters('virtualMachineName'),'/', 'SqlIaasExtension')]"존재하지 않습니다. 아래와 같이 수정해야 합니다.

   "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'),'/extensions/SqlIaasExtension')]"

이것을 확인할 수 있습니다링크.

OP에서 업데이트:

이름 필드를 'restoredb'에서 "[concat(parameters('virtualMachineName'),'/restoredb')]". 여러 customscriptextensions와 아무 관련이 없습니다

관련 정보