DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > PowerShell Script for Assigning Public IP Addresses to an Azure VM

PowerShell Script for Assigning Public IP Addresses to an Azure VM

We have a look at a Powershell script that will quickly assign a public IP to your Azure VM. Check it out!

Anindita Basak user avatar by
Anindita Basak
·
Jul. 27, 16 · Cloud Zone · Tutorial
Like (1)
Save
Tweet
5.09K Views

Join the DZone community and get the full member experience.

Join For Free

Recently, Azure virtual machines provisioned with the 'Resource Manager/Classic' deployment model have been provisioned with virtual IP and dynamic IP addresses, but not public IP address. A public IP address is necessary for accessing services deployed on VM from a local browser.

For example, in an Azure Linux VM, if you provision Apache Hadoop/Hortonworks Data Platform/Cloudera Hadoop Distribution, you may need to access the Hadoop services from a local browser in those addresses, like the HDFS service (http://<ip address of VM>:50070 and http://<ip address of VM>:50075) and MapReduce Service (http://<ip address of VM>:8080), etc.

In order to assign public IP addresses for an Azure Linux VM , you need to execute the following PowerShell script:


Get-AzureVM -ServiceName ‘azfilestorage’ -Name ‘azfilestorage’ | Set-AzurePublicIP -PublicIPName ‘linuxvmip’ | Update-AzureVM

#Next, update the VM with SSH Port 22 so that the VM can be accessed through SSH.
Get-AzureVM -Name ‘azfilestorage’ -ServiceName ‘azfilestorage’ | Set-AzureEndpoint -Protocol tcp -Name ‘SSH’ -PublicPort 22 -LocalPort 22 | Update-AzureVM

PS


Next, you can check the public IP address on Azure Portal under the "IP Address" section of Azure Virtual Machine:

IP-addr


And there you have it. Your Azure VM is now provisioned with a public IP address.

Virtual Machine azure PowerShell

Published at DZone with permission of Anindita Basak, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Is Sharding?
  • 3 Predictions About How Technology Businesses Will Change In 10 Years
  • Removing JavaScript: How To Use HTML With Htmx and Reduce the Amount of Code
  • Top 10 Criteria to Select the Best Angular Development Company

Comments

Cloud Partner Resources

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo