【问题标题】:set-AzureStaticVNetIP Is not setting static IP on Azure VMset-AzureStaticVNetIP 未在 Azure VM 上设置静态 IP
【发布时间】:2014-06-10 23:00:36
【问题描述】:

我正在尝试使用以下脚本设置 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

【问题讨论】:

    标签: powershell azure


    【解决方案1】:

    这行得通吗?

    $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;
    

    【讨论】:

    • 这个答案有帮助,但后来我得到“虚拟网络名称不能为空或为空。”
    • 我遇到了同样的问题。修复“虚拟网络名称不能为空...”后,您将收到另一个错误。见stackoverflow.com/questions/24833662/…
    【解决方案2】:

    所以,

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

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

    同时,您不能编辑虚拟机并即时添加保留的 IP 地址。

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

    卡住了。

    【讨论】:

      猜你喜欢
      • 2016-03-25
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 2014-09-10
      • 2021-11-28
      • 1970-01-01
      • 2021-07-14
      • 1970-01-01
      相关资源
      最近更新 更多