none
Add a network interface to an existing virtual machine with a problem RRS feed

答案

  • Hi Milo,

    The Command Update-AzureRmVM don't need the parameter "-Name", just remove the para : -Name "myVM01", and it will work fine.


    MSDN 社区技术支持
    如果该回复解决了您的问题,请及时点击“标记为答案”选项,如未解决请选择“取消标记为答案”,这会有利于其他人员来阅读您的帖子。如果您对MSDN 技术支持有任何的建议或意见,请随时联系 MSDNFSF@microsoft.com

    • 已标记为答案 Milo.zheng 2017年5月21日 11:51
    2017年5月19日 2:42
    版主
  • Hi David

    It's work now!

    the power sell code:

    PS C:\Users\milo.MEILV> $VirtualMachine = Get-AzureRmVM -ResourceGroupName "myvms" -Name "myvm01"
    Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id "/subscriptions/d34f92f1-ddbd-43ab-bd9a-1a5f88087c71/resourceGroups/MyVMs/providers/Microsoft.Network/networkInterfaces/Netport02" -Primary
    Update-AzureRmVM -ResourceGroupName "myvms"  -VM $VirtualMachine
    ResourceGroupName  : myvms
    Id                 : /subscriptions/d34f92f1-ddbd-43ab-bd9a-1a5f88087c71/resourceGroups/myvms/providers/Microsoft.Compute/virtualMachines/myVM01
    VmId               : 46b87680-428d-41b1-ac32-762d39659e46
    Name               : myVM01
    Type               : Microsoft.Compute/virtualMachines
    Location           : eastasia
    Tags               : {}
    DiagnosticsProfile : {BootDiagnostics}
    Extensions         : {enablevmaccess}
    HardwareProfile    : {VmSize}
    NetworkProfile     : {NetworkInterfaces}
    OSProfile          : {ComputerName, AdminUsername, WindowsConfiguration, Secrets}
    ProvisioningState  : Succeeded
    StorageProfile     : {ImageReference, OsDisk, DataDisks}

    RequestId           :
    IsSuccessStatusCode : True
    StatusCode          : OK
    ReasonPhrase        : OK

    thanks

    • 已标记为答案 Milo.zheng 2017年5月21日 11:50
    2017年5月21日 11:49
  • Hi Milo,

    Glad to hear you solve the problem.

    > But I don't know how to set another existing network interface to primary. the command Set-AzureRmNetworkInterfac seems that not have parameter "primary" to set.

    Usually we could use below command to change the primary NIC :

    # Show the Network interfaces $VM.NetworkProfile.NetworkInterfaces

    ------------echo----------------------------------------------------------------

    Primary Id
    ------- --
       True /subscriptions/e16d3293-****-****-****-d751964ccfc6/resourceGroups/...
      False /subscriptions/e16d3293-****-****-****-d751964ccfc6/resourceGroups/...

    ------------echo---------------------------------------------------------------- #i will change the second NIC to primary in this example $VM.NetworkProfile.NetworkInterfaces.Item(1).Primary = $true

    $VM.NetworkProfile.NetworkInterfaces.Item(0).Primary = $false

    #Update the VM configuration (The VM will be restarted) Update-AzureRmVM -VM $VM -ResourceGroupName $VMRG



    MSDN 社区技术支持
    如果该回复解决了您的问题,请及时点击“标记为答案”选项,如未解决请选择“取消标记为答案”,这会有利于其他人员来阅读您的帖子。如果您对MSDN 技术支持有任何的建议或意见,请随时联系 MSDNFSF@microsoft.com



    2017年5月22日 2:28
    版主

全部回复

  • Hi Milo,

    The Command Update-AzureRmVM don't need the parameter "-Name", just remove the para : -Name "myVM01", and it will work fine.


    MSDN 社区技术支持
    如果该回复解决了您的问题,请及时点击“标记为答案”选项,如未解决请选择“取消标记为答案”,这会有利于其他人员来阅读您的帖子。如果您对MSDN 技术支持有任何的建议或意见,请随时联系 MSDNFSF@microsoft.com

    • 已标记为答案 Milo.zheng 2017年5月21日 11:51
    2017年5月19日 2:42
    版主
  • Hi David thank you for kindly reply

    now it have another problem:

    Update-AzureRmVM : Virtual machine myVM01 must have one network interface set as the primary. ErrorCode: VirtualMachineMustHaveOneNetworkInterfaceAsPrimary ErrorMessage: Virtual machine myVM01 must have one network interface set as the primary. StatusCode: 400 ReasonPhrase: Bad Request OperationID : f30f3301-b607-40fa-8613-46fa73ff1799 所在位置 行:3 字符: 1 + Update-AzureRmVM -ResourceGroupName "MyVMs" -VM $VirtualMachine + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Update-AzureRmVM],ComputeCloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.UpdateAzureVMCommand

    how to set a network interface as primary?

    2017年5月19日 14:12
  • Hi David

    It's work now!

    the power sell code:

    PS C:\Users\milo.MEILV> $VirtualMachine = Get-AzureRmVM -ResourceGroupName "myvms" -Name "myvm01"
    Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id "/subscriptions/d34f92f1-ddbd-43ab-bd9a-1a5f88087c71/resourceGroups/MyVMs/providers/Microsoft.Network/networkInterfaces/Netport02" -Primary
    Update-AzureRmVM -ResourceGroupName "myvms"  -VM $VirtualMachine
    ResourceGroupName  : myvms
    Id                 : /subscriptions/d34f92f1-ddbd-43ab-bd9a-1a5f88087c71/resourceGroups/myvms/providers/Microsoft.Compute/virtualMachines/myVM01
    VmId               : 46b87680-428d-41b1-ac32-762d39659e46
    Name               : myVM01
    Type               : Microsoft.Compute/virtualMachines
    Location           : eastasia
    Tags               : {}
    DiagnosticsProfile : {BootDiagnostics}
    Extensions         : {enablevmaccess}
    HardwareProfile    : {VmSize}
    NetworkProfile     : {NetworkInterfaces}
    OSProfile          : {ComputerName, AdminUsername, WindowsConfiguration, Secrets}
    ProvisioningState  : Succeeded
    StorageProfile     : {ImageReference, OsDisk, DataDisks}

    RequestId           :
    IsSuccessStatusCode : True
    StatusCode          : OK
    ReasonPhrase        : OK

    thanks

    • 已标记为答案 Milo.zheng 2017年5月21日 11:50
    2017年5月21日 11:49
  • But I don't know how to set another existing network interface to primary. the command Set-AzureRmNetworkInterfac seems that not have parameter "primary" to set.
    2017年5月21日 12:01
  • Hi Milo,

    Glad to hear you solve the problem.

    > But I don't know how to set another existing network interface to primary. the command Set-AzureRmNetworkInterfac seems that not have parameter "primary" to set.

    Usually we could use below command to change the primary NIC :

    # Show the Network interfaces $VM.NetworkProfile.NetworkInterfaces

    ------------echo----------------------------------------------------------------

    Primary Id
    ------- --
       True /subscriptions/e16d3293-****-****-****-d751964ccfc6/resourceGroups/...
      False /subscriptions/e16d3293-****-****-****-d751964ccfc6/resourceGroups/...

    ------------echo---------------------------------------------------------------- #i will change the second NIC to primary in this example $VM.NetworkProfile.NetworkInterfaces.Item(1).Primary = $true

    $VM.NetworkProfile.NetworkInterfaces.Item(0).Primary = $false

    #Update the VM configuration (The VM will be restarted) Update-AzureRmVM -VM $VM -ResourceGroupName $VMRG



    MSDN 社区技术支持
    如果该回复解决了您的问题,请及时点击“标记为答案”选项,如未解决请选择“取消标记为答案”,这会有利于其他人员来阅读您的帖子。如果您对MSDN 技术支持有任何的建议或意见,请随时联系 MSDNFSF@microsoft.com



    2017年5月22日 2:28
    版主
  • thank you very much
    2017年5月23日 22:51