Provisioning a Public IP Address

Preview

Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in

Provisioning a Public IP Address

This guide shows you how to provision a Public IP Address against Locally. As with the other guides we're going to use the Azure CLI, but the same resources can be provisioned with HashiCorp Terraform, Pulumi or Bicep too.

Before you start

Plugin required

This requires the Microsoft.Network plugin, which you can install with:

$ locally plugin install --name Microsoft.Network

1. Start Locally

Firstly, we need to launch Locally which we can do from a terminal by running:

$ locally build

Once Locally has started, the Locally Dashboard will open automatically:

Screenshot of the Locally Dashboard

2. Create a Resource Group

Next we can create the Resource Group:

$ locally run az group create -n sample-resources -l berlin

There's two things to note here:

  1. The Azure CLI supports Automatic Configuration, meaning that it can automatically be configured to work against Locally just by prefixing commands with locally run.
  2. Locally intentionally uses a different set of locations to Azure as a safety precaution, so that you can be confident you're deploying against Locally rather than regular Azure. You can also configure Locally to use the Azure locations too, but you'll want to be extra sure that you're prefixing commands with locally run when you do.

3. Create the Public IP Address

With the Resource Group in place, we can create the Public IP Address. The two decisions worth making are the SKU and whether the address is statically or dynamically allocated:

$ locally run az network public-ip create -g sample-resources -n sample-pip --sku Standard --allocation-method Static
{
  "ip": "127.1.0.3",
  "method": "Static",
  "name": "sample-pip",
  "sku": "Standard",
  "state": "Succeeded"
}

Note

Locally allocates addresses from a loopback range on your machine rather than routable public addresses - so the shape of the resource matches Azure, but the address only means something locally. This means you can exercise the configuration without anything being reachable from the internet.

We can read the address back at any point, which is what you'd do when wiring it into something else:

$ locally run az network public-ip show -g sample-resources -n sample-pip --query "{name:name, ip:ipAddress, method:publicIPAllocationMethod, sku:sku.name}"

And list the addresses in the Resource Group:

$ locally run az network public-ip list -g sample-resources --query "[].{Name:name, IP:ipAddress, Method:publicIPAllocationMethod}" -o table
Name        IP          Method
----------  ----------  --------
sample-pip  127.1.0.3   Static

A Public IP Address on its own doesn't do much - it becomes useful once attached to something, such as a Load Balancer or a virtual machine's network interface.

We can see the Public IP Address in the Locally Dashboard too:

Screenshot of the Public IP Address in the Locally Dashboard

4. Tidy up

Finally, we can tidy up. To remove the Resource Group and everything within it:

$ locally run az group delete -n sample-resources --yes

There's nothing billable to clean up, since everything ran on your machine, but it's still worth checking your teardown scripts work here before you run them against Azure.

Doing this with other tooling

Whilst this guide used the Azure CLI, Public IP Addresses work the same way through any of the tooling that Locally supports - a Microsoft.Network/publicIPAddresses resource in HashiCorp Terraform or OpenTofu, Pulumi, Bicep or an ARM Template all provision against Locally in the same way, with only the location changed.

Next steps

A NAT Gateway uses a Public IP for outbound traffic. With a Public IP on a Virtual Machine, you can connect to it with the Locally CLI - see Virtual Machines.

Should you encounter any issues, please take a look at the troubleshooting section.

Preview

Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in

A local cloud for you and your AI agents.

Your Azure infrastructure, running on your machine. Deploy in seconds, break things freely, and ship to Azure when you're ready.