为什么Azure无法在PowerShell命令中找到配置配置?

时间:2015-01-13 17:41:41

标签: powershell azure deployment provisioning piping

我尝试使用下面的PowerShell命令部署Azure VM,并且我收到了无用的错误。

阻止Azure识别配置配置。

我还完全从命令中删除了反恶意软件JSON并进行了测试,但没有区别 - 所以至少我知道它并不是所有转义引号的问题。

注意:这是在一行中执行的 - 我在StackOverflow上添加了换行符以便于阅读。

New-AzureVMConfig -Name "TestVM" -Label "TestVM" -InstanceSize "extra small" -HostCaching "ReadWrite" -AvailabilitySetName "TestAvailabilitySet" -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201412.01-en.us-127GB.vhd" -MediaLocation "https://teststorageaccount.blob.core.windows.net/vhds/TestDisk.vhd" -DiskLabel "TestDisk"
| Add-AzureProvisioningConfig -Windows –Password "xxxxxxxx" -ResetPasswordOnFirstLogon -NoRDPEndpoint -NoWinRMEndpoint -TimeZone "Pacific Time (US & Canada)"
| Set-AzureVMMicrosoftAntimalwareExtension -AntimalwareConfiguration "{ `"AntimalwareEnabled`": true, `"RealtimeProtectionEnabled`": true, `"ScheduledScanSettings`": { `"isEnabled`": true, `"day`": 1, `"time`": 120, `"scanType`": `"Full`" } }"
| Set-AzureSubnet –SubnetNames "TestSubnet"
| Set-AzureStaticVNetIP -IPAddress "x.x.x.x"
| New-AzureVM -ServiceName "TestService" -DeploymentLabel "TestDeployment" -DeploymentName "TestDeployment" -VNetName "TestNetwork"

这是显示的错误消息:

New-AzureVM : Virtual Machine TestVM is missing provisioning configuration
At line:1 char:829
+ New-AzureVMConfig -Name "TestVM" -Label "TestVM" -InstanceSize "extra  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureVM], ArgumentException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewAzureVMCommand

1 个答案:

答案 0 :(得分:1)

我发现了几个问题:

1)Add-AzureProvisioningConfig命令显然需要-AdminUsername参数,我根据我在互联网上找到的较旧(遗留)示例省略了该参数。

2)不推荐使用-ResetPasswordOnFirstLogon标志,在删除命令之前,命令不会继续。再一次,显然我已经阅读了太多旧的和不相关的教程。

3)VM大小应为ExtraSmall而不是extra small

有效的最终命令,如下所示:

New-AzureVMConfig -Name "TestVM" -Label "TestVM" -InstanceSize "ExtraSmall" -HostCaching "ReadWrite" -AvailabilitySetName "TestAvailabilitySet" -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201412.01-en.us-127GB.vhd" -MediaLocation "https://teststorageaccount.blob.core.windows.net/vhds/TestDisk.vhd" -DiskLabel "TestDisk"
| Add-AzureProvisioningConfig -Windows -AdminUsername "LocalAdmin" –Password "xxxxxxxx" -NoRDPEndpoint -NoWinRMEndpoint -TimeZone "Pacific Time (US & Canada)"
| Set-AzureVMMicrosoftAntimalwareExtension -AntimalwareConfiguration "{ `"AntimalwareEnabled`": true, `"RealtimeProtectionEnabled`": true, `"ScheduledScanSettings`": { `"isEnabled`": true, `"day`": 1, `"time`": 120, `"scanType`": `"Full`" } }"
| Set-AzureSubnet –SubnetNames "TestSubnet"
| Set-AzureStaticVNetIP -IPAddress "x.x.x.x"
| New-AzureVM -ServiceName "TestService" -DeploymentLabel "TestDeployment" -DeploymentName "TestDeployment" -VNetName "TestNetwork"