move a VM to another subnet - Update-AzureVM : BadRequest: The virtual network I

Welcome Forums General PowerShell Q&A move a VM to another subnet - Update-AzureVM : BadRequest: The virtual network I

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 7 months ago.

  • Author
  • #25150

    Points: 0
    Rank: Member

    Hi, I am following instructions on moving an existing VM in Azure to a Different Subnet as indicated at the url

    After adding my account, selecting scription and do Get-AzureVM, I get the following error

    Update-AzureVM : BadRequest: The virtual network ID cannot be null or empty.
    At line:1 char:7
    + $vm | Update-AzureVM
    + ~~~~~~~~~~~~~~
    + CategoryInfo : CloseError: [:] [Update-AzureVM], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.UpdateAzureVMCommand

    The command

    Get-AzureVM –ServiceName TestVMCloud –Name TestVM | Set-AzureSubnet –SubnetNames Subnet-2 | Update-AzureVM

    has no parameter "Virtual network ID", so what is missing here?

    was using variables when getting the mentioned error like this

    Get-AzureVM-ServiceName $cloudServiceName -Name $vmName | Set-AzureSubnet -SubnetNames $subnetname | Update-AzureVM

    I replaced the variables with there values as follows (without quotes as suggested)

    Get-AzureVM -ServiceName myservice -Name MyAVM2 | Set-AzureSubnet -SubnetNames mysubnet | Update-AzureVM

    it did not work, I also tried using quotes

    Get-AzureVM -ServiceName 'myservice' -Name 'MyAVM2' | Set-AzureSubnet -SubnetNames 'mysubnet' | Update-AzureVM

    I opened a thread on MS forums, they request to open a ticket and my subscription is an MSDN related subscription which has no technical support


  • #25154

    Points: 303
    Helping Hand
    Rank: Contributor

    Are you sure the subnet you are referencing is correct? It looks like there is a Get-AzureVnetSite cmdlet that lists the available subnets, so can you do Get-AzureVnetSite -VnetName mysubnet and access the subnet? My guess is that Set-AzureSubnet is doing a similar look up and cannot find the subnet with that name, so it's null.

  • #25179

    Points: 0
    Rank: Member

    Dear Rob, executing only Get-AzureVnetSite or Get-AzureVnetSite -VNetName myNetwork

    AddressSpacePrefixes : {}
    Location : North Europe
    AffinityGroup :
    DnsServers : {salammain}
    GatewayProfile : Small
    GatewaySites : {}
    Id : *****************
    InUse : False
    Label :
    Name : salam****************k
    State : Created
    Subnets : {Subnet-1, GatewaySubnet}
    OperationDescription : Get-AzureVNetSite
    OperationId : 540d9a6a-3515-a147-b0e6-e725e4e65a9a
    OperationStatus : Succeeded

    So I have a subnet named "Subnet-1"

    when I run
    Get-AzureVnetSite -VNetName Subnet-1 or
    Get-AzureVnetSite -VNetName 'Subnet-1' or "Get-AzureVnetSite -VNetName Subnet-1"

    I get
    Get-AzureVNetSite : There were not enough free threads in the ThreadPool to complete the operation.

    Thanks again

The topic ‘move a VM to another subnet - Update-AzureVM : BadRequest: The virtual network I’ is closed to new replies.