Azure ARM шаблон "VmAgentNotRunning" - PullRequest
0 голосов
/ 07 февраля 2020

Я пытаюсь создать шаблон для SQL развертываний IaaS, включая виртуальную машину, расширение SQL IaaS и компьютер SQL IaaS. Я получаю сообщение об ошибке при развертывании компьютера SQL IaaS, поскольку виртуальная машина еще не полностью завершила развертывание.

Мой текущий шаблон выглядит следующим образом:

        {
            "name": "[parameters('virtualMachineName')]",
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2018-10-01",
            "location": "[variables('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
            ],
            "properties": {
                "hardwareProfile": {
                    "vmSize": "[parameters('virtualMachineSize')]"
                },
                "osProfile": {
                    "computerName": "[parameters('virtualMachineName')]",
                    "adminUsername": "",
                    "adminPassword": "",
                    "windowsConfiguration": {
                        "provisionVMAgent": true
                    }
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "MicrosoftSQLServer",
                        "offer": "[variables('sqlOffer')]",
                        "sku": "[parameters('sqlEdition')]",
                        "version": "latest"
                    },
                    "osDisk": {
                        "createOption": "FromImage",
                        "osType": "Windows",
                        "caching": "ReadWrite",
                        "name": "[variables('OSDiskName')]",
                        "managedDisk": {
                            "storageAccountType": "Premium_LRS"
                        }
                    },
                    "dataDisks": [
                        {
                            "name": "[concat(parameters('virtualMachineName'),'-DATA1')]",
                            "createOption": "Empty",
                            "managedDisk": {
                                "storageAccountType": "StandardSSD_LRS"
                            },
                            "lun": 0,
                            "diskSizeGB": "[parameters('sizeOfUserDBDiskInGB')]",
                            "caching": "ReadOnly"
                        },
                        {
                            "name": "[concat(parameters('virtualMachineName'),'-DATA2')]",
                            "createOption": "Empty",
                            "managedDisk": {
                                "storageAccountType": "Standard_LRS"
                            },
                            "lun": 1,
                            "diskSizeGB": 128,
                            "caching": "ReadOnly"
                        },
                        {
                            "name": "[concat(parameters('virtualMachineName'),'-DATA3')]",
                            "createOption": "Empty",
                            "managedDisk": {
                                "storageAccountType": "Standard_LRS"
                            },
                            "lun": 2,
                            "diskSizeGB": 1023,
                            "caching": "ReadOnly"
                        },
                        {
                            "name": "[concat(parameters('virtualMachineName'),'-DATA4')]",
                            "createOption": "Empty",
                            "managedDisk": {
                                "storageAccountType": "Standard_LRS"
                            },
                            "lun": 4,
                            "diskSizeGB": 512,
                            "caching": "ReadOnly"
                        },
                        {
                            "name": "[concat(parameters('virtualMachineName'),'-DATA5')]",
                            "createOption": "Empty",
                            "managedDisk": {
                                "storageAccountType": "Standard_LRS"
                            },
                            "lun": 5,
                            "diskSizeGB": 512,
                            "caching": "None"
                        },
                        {
                            "name": "[concat(parameters('virtualMachineName'),'-DATA6')]",
                            "createOption": "Empty",
                            "managedDisk": {
                                "storageAccountType": "Standard_LRS"
                            },
                            "lun": 6,
                            "diskSizeGB": 512,
                            "caching": "None"
                        }
                    ]
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "[reference(resourceId(resourceGroup().name, 'Microsoft.Storage/storageAccounts', parameters('diagnosticsStorageAccountName')), '2015-06-15').primaryEndpoints['blob']]"
                    }
                }
            },
            "tags": {
                "Application Stack": "[parameters('Application Stack')]",
                "Business Contact": "[parameters('Business Contact')]",
                "Associated to": "[resourceGroup().name]",
                "Business Owner": "[parameters('Business Owner')]",
                "BusinessUnit": "[parameters('Business Unit')]",
                "Department": "[parameters('Department')]",
                "Region": "[parameters('Region')]",
                "Type": "[variables('VMType')]"
            }
        },
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(parameters('virtualMachineName'), '/SqlIaasExtension')]",
            "location": "[variables('location')]",
            "dependsOn": [
                "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
            ],
            "properties": {
                "type": "SqlIaaSAgent",
                "publisher": "Microsoft.SqlServer.Management",
                "typeHandlerVersion": "1.2",
                "autoUpgradeMinorVersion": "true",
                "settings": {
                    "AutoTelemetrySettings": {
                        "Region": "[variables('location')]"
                    },
                    "AutoPatchingSettings": {
                        "PatchCategory": "WindowsMandatoryUpdates",
                        "Enable": true,
                        "DayOfWeek": "Saturday",
                        "MaintenanceWindowStartingHour": "2",
                        "MaintenanceWindowDuration": "180"
                    },
                    "ServerConfigurationsManagementSettings": {
                        "SQLConnectivityUpdateSettings": {
                            "ConnectivityType": "Private",
                            "Port": "1433"
                        },
                        "SQLWorkloadTypeUpdateSettings": {
                            "SQLWorkloadType": "General"
                        },
                        "SQLStorageUpdateSettings": {
                            "DiskCount": 1,
                            "NumberOfColumns": 1,
                            "StartingDeviceID": "2",
                            "DiskConfigurationType": "NEW"
                        },
                        "AdditionalFeaturesServerConfigurations": {
                            "IsRServicesEnabled": "false"
                        }
                    }
                },
                "protectedSettings": {
                    "SQLAuthUpdateUserName": "",
                    "SQLAuthUpdatePassword": ""
                }
            }
        },
        {
            "type": "Microsoft.SqlVirtualMachine/sqlVirtualMachines",
            "apiVersion": "2017-03-01-preview",
            "name": "[parameters('virtualMachineName')]",
            "location": "[variables('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]"
            ],
            "properties": {
                "virtualMachineResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
                "sqlImageOffer": "[variables('sqlOffer')]",
                "sqlServerLicenseType": "AHUB",
                "sqlManagement": "Full",
                "sqlImageSku": "[parameters('sqlEdition')]"
            }
        }

Эта последняя часть развертывается компьютер Azure SQL IaaS, который зависит от работающего агента VM. Я получаю сообщение об ошибке:

    "error": {
        "code": "VmAgentNotRunning",
        "message": "The VM agent in Virtual Machine: '/subscriptions/{GUID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Compute/virtualMachines/{VmName}' is not in running state. Please make sure it is installed and in running state and try again later."
    }

Есть ли способ добавить ожидание или добавить зависимость от агента, запущенного перед развертыванием компьютера SQL IaaS? Без этого шаблон отлично работает. После развертывания машины я могу запустить скрипт powershell для создания объекта, но я стараюсь этого избежать. Заранее спасибо.

1 Ответ

0 голосов
/ 16 марта 2020

Случайно обнаружил эту статью, которая объясняет мою проблему. https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/virtual-machines-windows-sql-register-with-resource-provider?tabs=azure-cli%2Cpowershell#management -modes

Хитрость заключалась в том, чтобы изменить "sqlManagement": "Full", на "sqlManagement": "LightWeight",

...