Skip to content

Scripts from exploring Azure CLI and PowerShell.

Notifications You must be signed in to change notification settings

wmelvin/try-az-pwsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

try-az-pwsh

Exploring Azure and PowerShell

This repository contains some scripts from my experimenting with using PowerShell to automate creating virtual machines in Azure. These scripts are not comprehensive or immediately reusable. They are here mainly for my future reference. If anyone else finds some useful bits, that's a bonus. ;-)

Scripts

az-create-linux-vm.ps1 - Creates a Linux VM for testing and configures SSH access.

az-create-win-vm.ps1 - Creates a Windows VM for testing and opens the port for RDP access.

az-funcs.ps1 - Contains several shared functions; dot-sourced by the other scripts.

az-snips.ps1 - Contains various PowerShell commands. The commands are commented out. I run them in Visual Studio Code (or the PowerShell ISE) by selecting the text and pressing F8.

There are setup steps needed before the scripts can be used:

The Azure CLI must be installed.

The PowerShell session must be signed in to Azure.

I store the credentials for the virtual machines in files kept in a separate local folder. The files are short PowerShell scripts that simply set variables to be referenced from the running script by dot-sourcing them.

Example win-vm-creds-1.ps1:

$VMUser = "badmin"
$VMPass = "badpassword123"

To create a Linux VM with SSH access, a SSH key is needed. I have a generated public key in ~/.ssh/id_rsa.pub that is uploaded in the az vm create step.

Reference

Microsoft Docs

az group create

az network vnet create

az network public-ip create

az network nsg create

az network nic create

az vm open-port

az vm create

az vm list-ip-addresses

Other

Pro Git book - Generating Your SSH Public Key

GitHub - Generating a new SSH key

About

Scripts from exploring Azure CLI and PowerShell.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published