participant
participant

Reputation: 3003

Obtain a ConnectionURI for an Azure VM (ARM)

Q How can I obtain a ConnectionURI for an Azure VM (ARM)?

Note In ASM (classic vm) one could simply use the Connect-AzureVM.ps1 to obtain the ConnectionURI.

Upvotes: 0

Views: 204

Answers (2)

Shui shengbao
Shui shengbao

Reputation: 19195

For ARM VM, the ConnectionURI is <Azure VM Public IP Address>:port. You could use PowerShell to get your VM public IP. Public IP is a resource VM, you could assign a Public IP to a VM

$ip=Get-AzureRmPublicIpAddress -ResourceGroupName <resource group name> -Name <public IP name>

$ip.IpAddress

You also could get Public IP on Azure Portal.

enter image description here

You could WinRM your VM by using following cmdlets.

Enter-PSSession -ConnectionUri https://<public-ip-dns-of-the-vm>:port -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck) -Authentication Negotiate

Upvotes: 1

4c74356b41
4c74356b41

Reputation: 72171

By default Azure doesn't assign a dns name for you public IP, so there's only the IP address. So you can get that by making calls to Get-AzureRmPublicIpAddress (if you know the name.

if you don't you can go the long route and get the VM network interface and get the publicipaddress from that

Something like:

$vm = Get-AzureRmVm -Name xxx -ResourceGroup yyy
$nicName = ($vm.NetworkInterfaceIDs[0] -split '/')[-1]
$pip = (Get-AzureRmNetworkInterface -Name $nicName -ResourceGroupName yyy).IpConfigurations.publicipaddress.id
(Get-AzureRmPublicIpAddress -ResourceGroupName yyy -Name ($pip -split '/')[-1]).DnsSettings.fqdn

something like that, or you could use ipaddress property for the public IP. So not FQDN.

Upvotes: 1

Related Questions