set-AzureStaticVNetIP未在Azure VM上设置静态IP

时间:2014-06-10 23:00:37

标签: powershell azure

我正在尝试使用以下脚本设置VM的IP。然而,它返回了我无法解决的这个神秘错误。

$cloudSvcName = "My-SPService";
Test-AzureStaticVNetIP –VNetName My-SPNetwork –IPAddress 10.0.0.4
$dns = Get-AzureVM -Name "My-DNS" -ServiceName $cloudSvcName ;
stop-AzureVM -Name  $dns.Name -ServiceName $cloudSvcName -Force;
set-AzureStaticVNetIP -VM $dns -IPAddress 10.0.0.4 | update-AzureVM;

这是错误:

[ERROR] update-AzureVM : BadRequest: The value for parameter 'SubnetNames' is null or empty.
[ERROR] At C:\Users\Tim\Source\Repos\Powershell Azure\AzurePowerShell\ScratchPad.ps1:12 char:104
[ERROR] + ... ess 10.0.0.4 | update-AzureVM -ServiceName $cloudSvcName;
[ERROR] +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR]     + CategoryInfo          : CloseError: (:) [Update-AzureVM], CloudException
[ERROR]     + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.UpdateAzureVMCommand

2 个答案:

答案 0 :(得分:3)

这有用吗?

$sub = "PubSubnet";  #Set to whatever subnet you have set up

$cloudSvcName = "My-SPService";
Test-AzureStaticVNetIP –VNetName My-SPNetwork –IPAddress 10.0.0.4
$dns = Get-AzureVM -Name "My-DNS" -ServiceName $cloudSvcName ;
stop-AzureVM -Name  $dns.Name -ServiceName $cloudSvcName -Force;

$dns | Set-AzureSubnet –SubnetNames $sub | set-AzureStaticVNetIP -IPAddress 10.0.0.4 | update-AzureVM;

答案 1 :(得分:-1)

所以,

如果您使用的是保留IP地址,目前Azure不支持设置内部IP地址。

但您可以在创建VM时分配静态内部IP地址。

同时,您无法动态编辑VM并添加保留的IP地址。

总结 - 您不能在VM中一次使用静态内部IP地址与VNet和保留IP地址。

被困住了。