Set-AzurePublicIP
Adds a Public IP to an Azure virtual machine.
Note
The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.
The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.
Syntax
Set-AzurePublicIP
[-PublicIPName] <String>
[[-IdleTimeoutInMinutes] <Int32>]
[[-DomainNameLabel] <String>]
-VM <IPersistentVM>
[-Profile <AzureSMProfile>]
[-InformationAction <ActionPreference>]
[-InformationVariable <String>]
[<CommonParameters>]
Description
The Set-AzurePublicIP cmdlet adds a Public IP to an Azure virtual machine. If you run this cmdlet for an existing virtual machine, update the virtual machine to implement your changes. You can specify a domain name label to create a corresponding DNS entry for the public IP.
Examples
Example 1: Add a Public IP to an existing virtual machine
PS C:\> Get-AzureVM -ServiceName "FTPInAzure" -Name "FTPInstance" | Set-AzurePublicIP -PublicIPName "ftpip" | Update-AzureVM
This command gets the virtual machine named FTPInstance in the service named FTPInAzure by using the Get-AzureVM cmdlet. The command passes that virtual machine to the current cmdlet by using the pipeline operator. The current cmdlet adds the Public IP name ftpip. The command passes the virtual machine to the Update-AzureVM cmdlet, which implements your changes.
Example 2: Add a Public IP to a new virtual machine
PS C:\> New-AzureVMConfig -Name "FTPInstance" -InstanceSize Small -ImageName "Image07" | Add-AzureProvisioningConfig -Windows -AdminUsername "AdminMain" -Password "password" | Set-AzurePublicIP -PublicIPName "ftpip" | New-AzureVM -ServiceName "FTPinAzure" -Location "North Central US"
This command creates a virtual machine configuration object by using the New-AzureVMConfig cmdlet. The command passes that object to the Add-AzureProvisioningConfig cmdlet, which provides additional configuration. The current cmdlet adds the Public IP name ftpip. The command passes the configuration to the New-AzureVM cmdlet, which creates the virtual machine.
Example 3: Add a Public IP and label to an existing virtual machine
PS C:\> Get-AzureVM -ServiceName "FTPInAzure" -Name "FTPInstance" | Set-AzurePublicIP -PublicIPName "ftpip" -DomainNameLabel "ipname" | Update-AzureVM
This command gets the virtual machine named FTPInstance in the service named FTPInAzure by using the Get-AzureVM cmdlet. The command passes that virtual machine to the current cmdlet by using the pipeline operator. The current cmdlet adds the Public IP name ftpip and the label ipname. The command updates the virtual machine, which implements your changes.
Example 4: Add a Public IP and label to a new virtual machine
PS C:\> New-AzureVMConfig -Name "FTPInstance" -InstanceSize Small -ImageName $images[50].ImageName | Add-AzureProvisioningConfig -Windows -AdminUsername "AdminMain" -Password "password" | Set-AzurePublicIP -PublicIPName "ftpip" -DomainNameLabel "ipname" | New-AzureVM -ServiceName "FTPinAzure" -Location "North Central US"
This command creates a virtual machine configuration object, and then passes that object to Add-AzureProvisioningConfig, which provides additional configuration. The current cmdlet adds the Public IP name ftpip and the label ipname. The command creates the virtual machine.
Parameters
-DomainNameLabel
Specifies the name to use for a corresponding DNS entry for the public IP address.
Type: | String |
Position: | 3 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-IdleTimeoutInMinutes
Specifies the TCP idle time-out period in minutes.
Type: | Int32 |
Position: | 2 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InformationAction
Specifies how this cmdlet responds to an information event.
The acceptable values for this parameter are:
- Continue
- Ignore
- Inquire
- SilentlyContinue
- Stop
- Suspend
Type: | ActionPreference |
Aliases: | infa |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InformationVariable
Specifies an information variable.
Type: | String |
Aliases: | iv |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Profile
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Type: | AzureSMProfile |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PublicIPName
Specifies the Public IP name.
Type: | String |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VM
Specifies the virtual machine to which this cmdlet adds Public IP.
Type: | IPersistentVM |
Aliases: | InputObject |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Outputs
Microsoft.WindowsAzure.Commands.ServiceManagement.Model.IPersistentVM