Carltonp
Carltonp

Reputation: 1344

Unable to Create Resource with Powershell in Azure

Can someone please tell me why I keep on getting the error shown in the image each time I attempt to create a NIC with Powershell in Azure?

NIC

Thank you

Upvotes: 1

Views: 64

Answers (1)

Bruno Faria
Bruno Faria

Reputation: 5272

You are not creating a Network Interface, instead, you are trying to get one that does not exist. To create a NIC, use the following procedures:

# Get the Virtual Network 
$VNET = Get-AzureRmVirtualNetwork -Name ‘Demo-vnet’ -ResourceGroupName ‘Demo’

# Get the Subnet Id
$SubnetID = (Get-AzureRmVirtualNetworkSubnetConfig -Name ‘default’ -VirtualNetwork $VNET).Id

# Create the Network Interface
New-AzureRmNetworkInterface -Name "NICFW" -ResourceGroupName "AdatumRG" -Location "East Us" -SubnetId $SubnetID 

Change variables accordingly and make sure -Location parameter matches your VNet location.

Upvotes: 1

Related Questions