<link href="https://fonts.googleapis.com/css?family=Roboto:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic&amp;display=swap" rel="stylesheet"/>
1 minute reading time (275 words)

Create Public IP address using Azure CLI

How to create a Public IP address using Azure CLI and attach it to a virtual machine Nic

Create public IP address using az network public-ip create

# define public ip address variables
rgName=prod-ukw-core-rg
ipName=prod-ukw-winx01-pip
allocationMethod=static
sku=basic
ipVersion=IPv4

az network public-ip create \
-g $rgName -n $ipName \
--allocation-method $allocationMethod \
--sku $sku \
--version $ipVersion 

Associate the public IP address to a virtual machine Nic

# define vm nic variables
configName=ipconfigprod-ukw-winx01
nicName=prod-ukw-winx01VMNic
rgName=prod-ukw-core-rg
pip=prod-ukw-winx01-pip

az network nic ip-config update \
  --name $configName \
  --nic-name $nicName \
  --resource-group $rgName \
  --public-ip-address $pip 

We won't be able to connect the VM using the new public IP because our existing subnet nsg doesn't have any inbound rules allowing Remote desktop port 3389.

In the next guide, we will create inbound rules for the nsg allowing port 3389 for RDP but restricting the source IP address to give some protection from password spray attacks.

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Tuesday, 30 April 2024
You can help support this website by buying me a coffee!
Buy Me A Coffee