compute

package
v0.0.0-...-57c00fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateVM

func CreateVM(ctx context.Context, vmName, nicName, username, password, storageAccountName, sshPublicKeyPath string) (vm hybridcompute.VirtualMachine, err error)

CreateVM creates a new virtual machine with the specified name using the specified network interface and storage account. Username, password, and sshPublicKeyPath determine logon credentials.

Example
var groupName = config.GenerateGroupName("HybridVM")
config.SetGroupName(groupName)

ctx := context.Background()
defer hybridresources.Cleanup(ctx)
_, err := hybridresources.CreateGroup(ctx)
if err != nil {
	util.LogAndPanic(err)
}
_, err = hybridnetwork.CreateVirtualNetworkAndSubnets(ctx, virtualNetworkName, subnetName)
if err != nil {
	util.LogAndPanic(err)
}
util.PrintAndLog("created vnet and a subnet")

_, err = hybridnetwork.CreateNetworkSecurityGroup(ctx, nsgName)
if err != nil {
	util.LogAndPanic(err)
}
util.PrintAndLog("created network security group")

_, err = hybridnetwork.CreatePublicIP(ctx, ipName)
if err != nil {
	util.LogAndPanic(err)
}
util.PrintAndLog("created public IP")

_, err = hybridnetwork.CreateNetworkInterface(ctx, nicName, nsgName, virtualNetworkName, subnetName, ipName)
if err != nil {
	util.LogAndPanic(err)
}
util.PrintAndLog("created nic")

_, err = hybridstorage.CreateStorageAccount(ctx, storageAccountName)
if err != nil {
	util.LogAndPanic(err)
}
util.PrintAndLog("created storage account")

_, err = CreateVM(ctx, vmName, nicName, username, password, storageAccountName, sshPublicKeyPath)
if err != nil {
	util.LogAndPanic(err)
}
util.PrintAndLog("created VM")
Output:

created vnet and a subnet
created network security group
created public IP
created nic
created storage account
created VM

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL