How to create multiple vm by using powershell

Punitha Keswani 20 Reputation points
2024-05-13T08:47:48.07+00:00

Hi Team,

I am creating multiple virtual machine by using powershell script.

I am getting below error. How can I fix this.

New-AzNetworkInterface : Cannot attach a Standard public IP address '/subscriptions/e06136ac-e2b0-4ba9-8b70-a6274295ed26/resourceGroups/Multivm1/providers/Microsoft.Network/publicIPAddresses/PublicIP3' to an IP configuration

'/subscriptions/e06136ac-e2b0-4ba9-8b70-a6274295ed26/resourceGroups/Multivm1/providers/Microsoft.Network/networkInterfaces/NIC3/ipConfigurations/IPConfig3' that has no reference to a subnet.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,003 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,598 questions
0 comments No comments
{count} votes

Accepted answer
  1. akinbade abiola 18,305 Reputation points
    2024-05-13T09:01:50.2433333+00:00

    Hello Punitha Keswani,

    Thanks for your question.

    From the error message you provided, it seems that the IP config for your NIC does not have a reference to a subnet

    I would recommend the following:

    1. Ensure you have a Subnet defined in the Vnet where the VM will be deployed
    2. Attach the subnet to the nic config. This can be done using https://learn.microsoft.com/en-us/powershell/module/az.network/new-aznetworkinterfaceipconfig?view=azps-11.6.0

    You can test and confirm.

    Also please see https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/associate-public-ip-address-vm?tabs=azure-portal

    Please let me know if you have further questions

    You can mark it 'Accept Answer' if this helped.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Virender Singh Rawat 67 Reputation points
    2024-05-13T10:22:28.7433333+00:00

    Hi, please share your script, and will confirm where you are wrong.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.