Microsoft Azure (AZ-104): PowerShell Script / Azure CLI

az group create 
--name CreateVNetQS-rg
--location eastus
az network vnet create 
--name myVNet
--resource-group CreateVNetQS-rg
--subnet-name default
az vm create 
--resource-group CreateVNetQS-rg
--name myVM1
--image UbuntuLTS
--public-ip-address myPublicIP-myVM1
$diskConfig = New-AzDiskConfig 
-Location "EastUS"
-CreateOption Empty
-DiskSizeGB 128
$dataDisk = New-AzDisk 
-ResourceGroupName "myResourceGroupDisk"
-DiskName "myDataDisk"
-Disk $diskConfig
$vm = 
-ResourceGroupName "myResourceGroupDisk"
-Name "myVM"
$vm = Add-AzVMDataDisk     
-VM $vm
-Name "myDataDisk"
-CreateOption Attach
-ManagedDiskId $dataDisk.Id
-Lun 1
-ResourceGroupName “myResourceGroupDisk”
-VM $vm
az vmss scale 
--resource-group myResourceGroup
--name myScaleSet
--new-capacity 5
$role = Get-AzRoleDefinition "Virtual Machine Contributor"
$role.Id = $null
$role.Name = "Virtual Machine Operator"
$role.Description = "Can monitor and restart virtual machines."
-Role $role
Move-AzResource -DestinationSubscriptionId
NOT Move-VMResource!!!
-Name 'CreatePubLBQS-rg'
-Location 'eastus'
$publicIp = Get-AzPublicIpAddress 
-Name 'myPublicIP'
-ResourceGroupName 'CreatePubLBQS-rg'
az network public-ip create
--resource-group CreatePubLBQS-rg
--name myPublicIP
--sku Standard
$feip = New-AzLoadBalancerFrontendIpConfig 
-Name 'myFrontEnd'
-PublicIpAddress $publicIp
az network lb create
--resource-group CreatePubLBQS-rg
--name myLoadBalancer
--sku Standard
--public-ip-address myPublicIP
--frontend-ip-name myFrontEnd
--backend-pool-name myBackEndPool
-ResourceGroupName "myresourcegroup"
-AccountName "mystorageaccount").IPRules
-ResourceGroupName "myresourcegroup"
-AccountName "mystorageaccount" -IPAddressOrRange ""
az storage account create 
--name <storage-account>
--resource-group <resource-group>

--location <location>
--sku Standard_ZRS
--encryption-services blob
az storage container create 
--account-name <storage-account>
--name <container>

--auth-mode login
az vm deallocate
--resource-group <>
--name demovm
az vm generalize
--resource-group <>
--name demovm
az image create
--resource-group <>
--name <imageName>
--source demovm
az network dns record-set a add-record 
--resource-group myresourcegroup
--record-set-name www
az network dns record-set a add-record
--resource-group myresourcegroup
--record-set-name "@"
az role definition create 
--role-definition @newrole.json



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
goay xuan hui

goay xuan hui

A food lover, a cyber security enthusiast, a musician and a traveller, so you will see a mix of different contents in my blog. ☺️