当我尝试使用PowerShell使用模板部署到azure时,我收到此错误:“不允许将可用性设置SKU从'对齐'更改为'经典'。”
这是我的模板文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.2",
"parameters": {
"tagvalues": {
"type": "object",
"defaultValue": {
"Owner": "Fill in",
"environment": "Fill in",
"Engagement": "Fill in",
"Role": "Fill in",
"LOB": "Fill in",
"Application": "Fill in"
}
},
"vmName": {
"type": "string",
"metadata": {
"description": "This is the name of the your VM"
}
},
"imageName": {
"type": "string",
"metadata": {
"description": "This is the name of the image file. Must end in .vhd"
}
},
"virtualNetworkName": {
"type": "string",
"metadata": {
"description": "Virtual Network Name"
}
},
"subnetName": {
"type": "string",
"metadata": {
"description": "Subnet Name"
}
},
"existingVnetResourceGroupName": {
"type": "string",
"metadata": {
"description": "Resource Group Name for Vnet"
}
},
"osStorageAccountName": {
"type": "string"
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_A2",
"metadata": {
"description": "This is the size of your VM"
}
},
"avSetName": {
"type":"string",
"metadata":{
"description": "Availability Set Name"
}
},
"adminUserName": {
"type": "string",
"defaultValue": "smadmin"
},
"adminPassword": {
"type": "securestring"
}
},
"variables": {
"vmName": "[parameters('vmName')]",
"nicName": "[concat(parameters('vmName'),'-Nic')]",
"osDiskVhdUri": "[concat('https://', parameters('osStorageAccountName'), '.blob.core.windows.net/vhds/', parameters('vmName'),'-osDisk.vhd')]",
"hostName": "[toLower(concat(parameters('vmName'), '.nix.us.company_world.company.com'))]",
"osType": "Linux",
"imageUri": "[concat('https://', parameters('osStorageAccountName'), '.blob.core.windows.net/images/',parameters('imageName'))]"
},
"resources": [
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"tags": {
"Owner": "[parameters('tagvalues').Owner]",
"environment": "[parameters('tagvalues').environment]",
"Engagement": "[parameters('tagvalues').Engagement]",
"Name": "[parameters('vmName')]",
"Role": "[parameters('tagvalues').Role]",
"LOB": "[parameters('tagvalues').LOB]",
"Application": "[parameters('tagvalues').Application]"
},
"location": "[resourceGroup().location]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[concat(resourceId(parameters('existingVnetResourceGroupName'), 'Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName')), '/subnets/',parameters('subnetName'))]"
}
}
}
]
}
},
{
"name": "[parameters('avSetName')]",
"type": "Microsoft.Compute/availabilitySets",
"location": "[resourceGroup().location]",
"apiVersion": "2016-04-30-preview",
"properties": {
"managed": "false",
"platformFaultDomainCount":3,
"platformUpdateDomainCount":3
},
"dependsOn": [ ],
"tags": {
"Owner": "[parameters('tagvalues').Owner]",
"environment": "[parameters('tagvalues').environment]",
"Engagement": "[parameters('tagvalues').Engagement]",
"Role": "[parameters('tagvalues').Role]",
"LOB": "[parameters('tagvalues').LOB]",
"Application": "[parameters('tagvalues').Application]"
}
},
{
"apiVersion": "2016-04-30-preview",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"tags": {
"Owner": "[parameters('tagvalues').Owner]",
"environment": "[parameters('tagvalues').environment]",
"Engagement": "[parameters('tagvalues').Engagement]",
"Role": "[parameters('tagvalues').Role]",
"LOB": "[parameters('tagvalues').LOB]",
"Application": "[parameters('tagvalues').Application]"
},
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
"[concat('Microsoft.Compute/availabilitySets/', parameters('avsetName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[variables('hostName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"osDisk": {
"name": "[concat(variables('vmName'),'-osDisk')]",
"osType": "[variables('osType')]",
"createOption": "FromImage",
"caching": "ReadWrite",
"image": {
"uri": "[variables('imageUri')]"
},
"vhd": {
"uri": "[variables('osDiskVhdUri')]"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": false
}
},
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',parameters('avSetName'))]"
}
}
}
],
"outputs": {
"ipAddress": {
"value": "[reference(variables('nicName')).ipConfigurations[0].properties.privateIPAddress]",
"type": "string"
}
}
}
这是我的参数文件:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.2",
"parameters": {
"tagvalues": {
"value": {
"Owner": "That Guy",
"environment": "Production",
"Engagement": "xxxxxxxxxx",
"Role": "Proxy",
"LOB": "Advisory",
"Application": "company Leasing Tool"
}
},
"vmName": {
"value": "machine_name"
},
"osStorageAccountName": {
"value": "vm_storage2"
},
"virtualNetworkName": {
"value": "vnet-prod-core1"
},
"subnetName": {
"value": "vnet-prod-core1-subnet-perimeter"
},
"existingVnetResourceGroupName": {
"value": "rg-core1",
"metadata": {
"description": "The resource group where the VNET is located."
}
},
"imageName": {
"value": "image-rhel-72-20170418.vhd",
"metadata": {
"description": "Enter the name of the image."
}
},
"vmSize": {
"value": "Standard_D1"
},
"avSetName": {
"value": "avset-proxy2",
"metadata": {
"description": "Name of availability set to add this VM. If it doesn't exist, it will be created."
}
},
"adminUsername": {
"value": "mysadmin"
},
"adminPassword": {
"value": "secret"
}
}
}
这是我用来尝试启动机器的powershell:
Login-AzureRmAccount
select-AzureRmSubscription -SubscriptionName "Asset.Prod"
$folder = "C:\Users\mysuer\Desktop\important_folders\Projects\repo\MS-Azure-Cloud\Templates\VirtualMachines\LinuxImageAvSet\" #Must end in trailing slash.
$rg = "rg-shared"
$template = "azuredeploy_unmanaged.json"
$param = "LinuxDeploymentsParameters/machine_name.params.json"
Test-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFile ($folder + $template) -TemplateParameterFile ($folder + $param) -Verbose
这是我得到的错误的完整输出:
New-AzureRmResourceGroupDeployment : 1:02:41 PM - Resource Microsoft.Compute/availabilitySets 'avset--proxy2' failed with message '{
"error": {
"code": "OperationNotAllowed",
"message": "Changing Availability Set SKU from 'Aligned' to 'Classic' is not allowed."
}
}'
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
VERBOSE: 1:02:41 PM - Resource Microsoft.Network/networkInterfaces 'machine_name-Nic' provisioning status is succeeded
VERBOSE: 1:02:41 PM - Checking deployment status in 5 seconds
New-AzureRmResourceGroupDeployment : 1:02:46 PM - Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for
usage details.
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzureRmResourceGroupDeployment : 1:02:46 PM - Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for
usage details.
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
我的文件位于正确的路径上:
ls -lh C:\Users\myser\Desktop\important_folders\Projects\repo\MS-Azure-Cloud\Templates\VirtualMachines\KTECHLinuxImageAvSet\azuredeploy_unmanaged.json
-rw-r--r-- 1 myser 1049089 6.0K Jun 9 13:02 'C:\Users\myser\Desktop\important_folders\Projects\repo\MS-Azure-Cloud\Templates\VirtualMachines\KTECHLinuxImageAvSet\azuredeploy_unmanaged.json'
ls C:\Users\myser\Desktop\important_folders\Projects\repo\MS-Azure-Cloud\Templates\VirtualMachines\company_tech_avset\LinuxDeploymentsParameters\machine_name.params.json
'C:\Users\myser\Desktop\important_folders\Projects\repo\MS-Azure-Cloud\Templates\VirtualMachines\company_tech_avset\LinuxDeploymentsParameters\machine_name.params.json'
如何更正此问题并解决此错误?
答案 0 :(得分:0)
根据您的描述,根本原因是,可用性集现在可用于虚拟机托管磁盘和非托管磁盘。
以下是新脚本,我们只能找到两个其他代码行“sku”和“名称”:“对齐”或“名称”:“经典强>“:
SELECT COUNT(*) FROM tablename
SELECT COUNT(columnname) FROM tablename
托管磁盘VM使用对齐的非托管磁盘使用classic。更多信息请参阅此official article。