Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Azure CLI – Convert VM Dynamic IP to Static IP

Posted on April 5, 2018 By David Kittell

If you create your VM with Dynamic IPs DHCP will grab the first available IP but some VMs are best on a static IP. This script below will get the existing IP of the ipconfig and reassign it to the same ipconfig as a static IP.

Dynamic_To_Static ()
{
nic="$4"
ipConfig="$5"
vmName="$3"
region="$2"
regionNS=$(tr -d ' ' <<< "$region")
resourceGroup=$(echo $1)

ConfigIP=$(az network nic ip-config show -g "$resourceGroup" --nic-name $(echo $nic) -n $(echo $ipConfig) --query "{ipConfigurations:privateIpAddress}" -o tsv)
az network nic ip-config update -g "$resourceGroup" --nic-name $(echo $nic) -n $(echo $ipConfig) --private-ip-address $ConfigIP
}
Dynamic_To_Static "RG-$(echo $regionNS)" $region $vmName $(echo $vmName)$(echo $regionNS)Nic "ipconfig1"
datetime=`date +%Y_%m_%d_%H.%M.%S`
echo "$(echo $vmName) Private IPs" > "$(echo $vmName)_$(echo $datetime).txt"
az network nic ip-config list --nic-name  $(echo $vmName)$(echo $regionNS)Nic  -g $resourceGroup -o table >> "$(echo $vmName)_$(echo $datetime).txt"
cat "$(echo $vmName)_$(echo $datetime).txt"
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Azure Azure CLI Azure CLI Functions Code

Post navigation

Previous post
Next post

Related Posts

PowerShell / Chocolatey Install WAMP

Posted on October 20, 2015October 20, 2015

Following the Chocolatey post we now install WAMP (Windows, Apache, MySQL, and PHP). Open PowerShell as administrator choco install -y wamp-server Configure WAMP for port 8080 copy "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf" "C:\wamp\bin\apache\apache2.4.9\conf\httpd_backup.conf" (gc "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf").replace(‘Listen 0.0.0.0:80′,’Listen 0.0.0.0:8080’) | sc "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf" (gc "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf").replace(‘Listen [::0]:80′,’Listen [::0]:8080’) | sc "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf" (gc "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf").replace(‘ServerName localhost:80′,’ServerName localhost:8080’) | sc "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf"…

Read More

Show Windows Version On Desktop

Posted on November 9, 2013October 26, 2015

WARNING: Backup the computer you try these scripts on before you run these. Windows Registry Editor Version 5.00 [[HKEY_CURRENT_USERControl PanelDesktop] "PaintDesktopVersion"=dword:00000000 Originally Posted on November 9, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program…

Read More

DirecTV – API JSON Service

Posted on January 3, 2018January 3, 2018

If you have your DirecTV Unit plugged into your network at home you could run a couple fun commands. #!/bin/sh # DirecTV.sh # # # Created by David Kittell on 1/3/18. # # Variables – Start unitIP="<IP ADDRESS>" # Variables – Stop # Get Unit Serial Number json=$(curl -s -X…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes