These samples demonstrate how to create Virtual Machines using the Azure SDK for Go on Azure Stack.
The code provided shows how to do the following:
Create a resource group
Create a virtual network
Create a security group
Create a public IP
Create a network interface
Create a storage account
Create a virtual machine
To see the code to perform these operations,
check out the main() function in app.go.
Each operation is clearly labeled with a comment and a print function.
Running this sample
Open a Powershell or Bash shell in ...\Hybrid-Golang-Samples\vm and enter the following command:
go mod init vm
Run the following to validate the go mod file with the required source code modules.
Azure will force the use of SSH over password authentication if both were configured. The sample code also enforces SSH key pair authentication over password authentication. The password authentication will be used if the SSH key pair path does not exist. The VM admin username will be VMAdmin. To run the sample, do one of either:
Create an SSH key at %HOMEPATH%/.ssh/id_rsa.pub for SSH key pair authentication.
go run app.go
Pass a string parameter as the VM admin password for password authentication.
go run app.go <PASSWORD>
Clean the resource group created during sample run.