We recommend using Azure Native.
Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
Use this data source to access information about an existing Public IP Address.
Example Usage
Reference An Existing)
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var example = Output.Create(Azure.Network.GetPublicIP.InvokeAsync(new Azure.Network.GetPublicIPArgs
{
Name = "name_of_public_ip",
ResourceGroupName = "name_of_resource_group",
}));
this.DomainNameLabel = example.Apply(example => example.DomainNameLabel);
this.PublicIpAddress = example.Apply(example => example.IpAddress);
}
[Output("domainNameLabel")]
public Output<string> DomainNameLabel { get; set; }
[Output("publicIpAddress")]
public Output<string> PublicIpAddress { get; set; }
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := network.GetPublicIP(ctx, &network.GetPublicIPArgs{
Name: "name_of_public_ip",
ResourceGroupName: "name_of_resource_group",
}, nil)
if err != nil {
return err
}
ctx.Export("domainNameLabel", example.DomainNameLabel)
ctx.Export("publicIpAddress", example.IpAddress)
return nil
})
}
Example coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.network.getPublicIP({
name: "name_of_public_ip",
resourceGroupName: "name_of_resource_group",
});
export const domainNameLabel = example.then(example => example.domainNameLabel);
export const publicIpAddress = example.then(example => example.ipAddress);
import pulumi
import pulumi_azure as azure
example = azure.network.get_public_ip(name="name_of_public_ip",
resource_group_name="name_of_resource_group")
pulumi.export("domainNameLabel", example.domain_name_label)
pulumi.export("publicIpAddress", example.ip_address)
Example coming soon!
Retrieve The Dynamic Public IP Of A New VM)
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "West Europe",
});
var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new Azure.Network.VirtualNetworkArgs
{
AddressSpaces =
{
"10.0.0.0/16",
},
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
});
var exampleSubnet = new Azure.Network.Subnet("exampleSubnet", new Azure.Network.SubnetArgs
{
ResourceGroupName = exampleResourceGroup.Name,
VirtualNetworkName = exampleVirtualNetwork.Name,
AddressPrefixes =
{
"10.0.2.0/24",
},
});
var examplePublicIp = new Azure.Network.PublicIp("examplePublicIp", new Azure.Network.PublicIpArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
AllocationMethod = "Dynamic",
IdleTimeoutInMinutes = 30,
Tags =
{
{ "environment", "test" },
},
});
var exampleNetworkInterface = new Azure.Network.NetworkInterface("exampleNetworkInterface", new Azure.Network.NetworkInterfaceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
IpConfigurations =
{
new Azure.Network.Inputs.NetworkInterfaceIpConfigurationArgs
{
Name = "testconfiguration1",
SubnetId = exampleSubnet.Id,
PrivateIpAddressAllocation = "Static",
PrivateIpAddress = "10.0.2.5",
PublicIpAddressId = examplePublicIp.Id,
},
},
});
var exampleVirtualMachine = new Azure.Compute.VirtualMachine("exampleVirtualMachine", new Azure.Compute.VirtualMachineArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
NetworkInterfaceIds =
{
exampleNetworkInterface.Id,
},
});
// ...
var examplePublicIP = Azure.Network.GetPublicIP.Invoke(new Azure.Network.GetPublicIPInvokeArgs
{
Name = examplePublicIp.Name,
ResourceGroupName = exampleVirtualMachine.ResourceGroupName,
});
this.PublicIpAddress = examplePublicIp.IpAddress;
}
[Output("publicIpAddress")]
public Output<string> PublicIpAddress { get; set; }
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/compute"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "exampleVirtualNetwork", &network.VirtualNetworkArgs{
AddressSpaces: pulumi.StringArray{
pulumi.String("10.0.0.0/16"),
},
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
})
if err != nil {
return err
}
exampleSubnet, err := network.NewSubnet(ctx, "exampleSubnet", &network.SubnetArgs{
ResourceGroupName: exampleResourceGroup.Name,
VirtualNetworkName: exampleVirtualNetwork.Name,
AddressPrefixes: pulumi.StringArray{
pulumi.String("10.0.2.0/24"),
},
})
if err != nil {
return err
}
examplePublicIp, err := network.NewPublicIp(ctx, "examplePublicIp", &network.PublicIpArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
AllocationMethod: pulumi.String("Dynamic"),
IdleTimeoutInMinutes: pulumi.Int(30),
Tags: pulumi.StringMap{
"environment": pulumi.String("test"),
},
})
if err != nil {
return err
}
exampleNetworkInterface, err := network.NewNetworkInterface(ctx, "exampleNetworkInterface", &network.NetworkInterfaceArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
IpConfigurations: network.NetworkInterfaceIpConfigurationArray{
&network.NetworkInterfaceIpConfigurationArgs{
Name: pulumi.String("testconfiguration1"),
SubnetId: exampleSubnet.ID(),
PrivateIpAddressAllocation: pulumi.String("Static"),
PrivateIpAddress: pulumi.String("10.0.2.5"),
PublicIpAddressId: examplePublicIp.ID(),
},
},
})
if err != nil {
return err
}
exampleVirtualMachine, err := compute.NewVirtualMachine(ctx, "exampleVirtualMachine", &compute.VirtualMachineArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
NetworkInterfaceIds: pulumi.StringArray{
exampleNetworkInterface.ID(),
},
})
if err != nil {
return err
}
_ = network.GetPublicIPOutput(ctx, network.GetPublicIPOutputArgs{
Name: examplePublicIp.Name,
ResourceGroupName: exampleVirtualMachine.ResourceGroupName,
}, nil)
ctx.Export("publicIpAddress", examplePublicIp.IpAddress)
return nil
})
}
Example coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("exampleVirtualNetwork", {
addressSpaces: ["10.0.0.0/16"],
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
});
const exampleSubnet = new azure.network.Subnet("exampleSubnet", {
resourceGroupName: exampleResourceGroup.name,
virtualNetworkName: exampleVirtualNetwork.name,
addressPrefixes: ["10.0.2.0/24"],
});
const examplePublicIp = new azure.network.PublicIp("examplePublicIp", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
allocationMethod: "Dynamic",
idleTimeoutInMinutes: 30,
tags: {
environment: "test",
},
});
const exampleNetworkInterface = new azure.network.NetworkInterface("exampleNetworkInterface", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
ipConfigurations: [{
name: "testconfiguration1",
subnetId: exampleSubnet.id,
privateIpAddressAllocation: "Static",
privateIpAddress: "10.0.2.5",
publicIpAddressId: examplePublicIp.id,
}],
});
const exampleVirtualMachine = new azure.compute.VirtualMachine("exampleVirtualMachine", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
networkInterfaceIds: [exampleNetworkInterface.id],
});
// ...
const examplePublicIP = azure.network.getPublicIPOutput({
name: examplePublicIp.name,
resourceGroupName: exampleVirtualMachine.resourceGroupName,
});
export const publicIpAddress = examplePublicIp.ipAddress;
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_virtual_network = azure.network.VirtualNetwork("exampleVirtualNetwork",
address_spaces=["10.0.0.0/16"],
location=example_resource_group.location,
resource_group_name=example_resource_group.name)
example_subnet = azure.network.Subnet("exampleSubnet",
resource_group_name=example_resource_group.name,
virtual_network_name=example_virtual_network.name,
address_prefixes=["10.0.2.0/24"])
example_public_ip = azure.network.PublicIp("examplePublicIp",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
allocation_method="Dynamic",
idle_timeout_in_minutes=30,
tags={
"environment": "test",
})
example_network_interface = azure.network.NetworkInterface("exampleNetworkInterface",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
ip_configurations=[azure.network.NetworkInterfaceIpConfigurationArgs(
name="testconfiguration1",
subnet_id=example_subnet.id,
private_ip_address_allocation="Static",
private_ip_address="10.0.2.5",
public_ip_address_id=example_public_ip.id,
)])
example_virtual_machine = azure.compute.VirtualMachine("exampleVirtualMachine",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
network_interface_ids=[example_network_interface.id])
# ...
example_public_ip = azure.network.get_public_ip_output(name=example_public_ip.name,
resource_group_name=example_virtual_machine.resource_group_name)
pulumi.export("publicIpAddress", example_public_ip.ip_address)
Example coming soon!
Using getPublicIP
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getPublicIP(args: GetPublicIPArgs, opts?: InvokeOptions): Promise<GetPublicIPResult>
function getPublicIPOutput(args: GetPublicIPOutputArgs, opts?: InvokeOptions): Output<GetPublicIPResult>def get_public_ip(name: Optional[str] = None,
resource_group_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetPublicIPResult
def get_public_ip_output(name: Optional[pulumi.Input[str]] = None,
resource_group_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetPublicIPResult]func GetPublicIP(ctx *Context, args *GetPublicIPArgs, opts ...InvokeOption) (*GetPublicIPResult, error)
func GetPublicIPOutput(ctx *Context, args *GetPublicIPOutputArgs, opts ...InvokeOption) GetPublicIPResultOutput> Note: This function is named GetPublicIP in the Go SDK.
public static class GetPublicIP
{
public static Task<GetPublicIPResult> InvokeAsync(GetPublicIPArgs args, InvokeOptions? opts = null)
public static Output<GetPublicIPResult> Invoke(GetPublicIPInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetPublicIPResult> getPublicIP(GetPublicIPArgs args, InvokeOptions options)
public static Output<GetPublicIPResult> getPublicIP(GetPublicIPArgs args, InvokeOptions options)
fn::invoke:
function: azure:network/getPublicIP:getPublicIP
arguments:
# arguments dictionaryThe following arguments are supported:
- Name string
- Specifies the name of the public IP address.
- Resource
Group stringName - Specifies the name of the resource group.
- Name string
- Specifies the name of the public IP address.
- Resource
Group stringName - Specifies the name of the resource group.
- name String
- Specifies the name of the public IP address.
- resource
Group StringName - Specifies the name of the resource group.
- name string
- Specifies the name of the public IP address.
- resource
Group stringName - Specifies the name of the resource group.
- name str
- Specifies the name of the public IP address.
- resource_
group_ strname - Specifies the name of the resource group.
- name String
- Specifies the name of the public IP address.
- resource
Group StringName - Specifies the name of the resource group.
getPublicIP Result
The following output properties are available:
- Allocation
Method string - Domain
Name stringLabel - The label for the Domain Name.
- Fqdn string
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
- Id string
- The provider-assigned unique ID for this managed resource.
- Idle
Timeout intIn Minutes - Specifies the timeout for the TCP idle connection.
- Ip
Address string - The IP address value that was allocated.
- Dictionary<string, string>
- A mapping of tags to assigned to the resource.
- Ip
Version string - The IP version being used, for example
IPv4orIPv6. - Location string
- Name string
- Resource
Group stringName - Reverse
Fqdn string - Sku string
- The SKU of the Public IP.
- Dictionary<string, string>
- A mapping of tags to assigned to the resource.
- Zones List<string>
- Allocation
Method string - Domain
Name stringLabel - The label for the Domain Name.
- Fqdn string
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
- Id string
- The provider-assigned unique ID for this managed resource.
- Idle
Timeout intIn Minutes - Specifies the timeout for the TCP idle connection.
- Ip
Address string - The IP address value that was allocated.
- map[string]string
- A mapping of tags to assigned to the resource.
- Ip
Version string - The IP version being used, for example
IPv4orIPv6. - Location string
- Name string
- Resource
Group stringName - Reverse
Fqdn string - Sku string
- The SKU of the Public IP.
- map[string]string
- A mapping of tags to assigned to the resource.
- Zones []string
- allocation
Method String - domain
Name StringLabel - The label for the Domain Name.
- fqdn String
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
- id String
- The provider-assigned unique ID for this managed resource.
- idle
Timeout IntegerIn Minutes - Specifies the timeout for the TCP idle connection.
- ip
Address String - The IP address value that was allocated.
- Map<String,String>
- A mapping of tags to assigned to the resource.
- ip
Version String - The IP version being used, for example
IPv4orIPv6. - location String
- name String
- resource
Group StringName - reverse
Fqdn String - sku String
- The SKU of the Public IP.
- Map<String,String>
- A mapping of tags to assigned to the resource.
- zones List<String>
- allocation
Method string - domain
Name stringLabel - The label for the Domain Name.
- fqdn string
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
- id string
- The provider-assigned unique ID for this managed resource.
- idle
Timeout numberIn Minutes - Specifies the timeout for the TCP idle connection.
- ip
Address string - The IP address value that was allocated.
- {[key: string]: string}
- A mapping of tags to assigned to the resource.
- ip
Version string - The IP version being used, for example
IPv4orIPv6. - location string
- name string
- resource
Group stringName - reverse
Fqdn string - sku string
- The SKU of the Public IP.
- {[key: string]: string}
- A mapping of tags to assigned to the resource.
- zones string[]
- allocation_
method str - domain_
name_ strlabel - The label for the Domain Name.
- fqdn str
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
- id str
- The provider-assigned unique ID for this managed resource.
- idle_
timeout_ intin_ minutes - Specifies the timeout for the TCP idle connection.
- ip_
address str - The IP address value that was allocated.
- Mapping[str, str]
- A mapping of tags to assigned to the resource.
- ip_
version str - The IP version being used, for example
IPv4orIPv6. - location str
- name str
- resource_
group_ strname - reverse_
fqdn str - sku str
- The SKU of the Public IP.
- Mapping[str, str]
- A mapping of tags to assigned to the resource.
- zones Sequence[str]
- allocation
Method String - domain
Name StringLabel - The label for the Domain Name.
- fqdn String
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
- id String
- The provider-assigned unique ID for this managed resource.
- idle
Timeout NumberIn Minutes - Specifies the timeout for the TCP idle connection.
- ip
Address String - The IP address value that was allocated.
- Map<String>
- A mapping of tags to assigned to the resource.
- ip
Version String - The IP version being used, for example
IPv4orIPv6. - location String
- name String
- resource
Group StringName - reverse
Fqdn String - sku String
- The SKU of the Public IP.
- Map<String>
- A mapping of tags to assigned to the resource.
- zones List<String>
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
