Vathsa's Cloud - Command Line steps and examples
Azure Command Line
Azure Create Custom OS Image & Deploy VM's :
az vm deallocate --resource-group atbial --name atbialServer
az vm generalize --resource-group atbial --name atbialServer
az image create --resource-group atbial --name atcentos7.4 --source atbialServer
az vm create --resource-group at_test_all --name atFrmImg --image "/subscriptions/a4d11e3d-98db-4857-b50e-6813049bbc66/resourceGroups/atbial/providers/Microsoft.Compute/images/atcentos74" --generate-ssh-keys
How To Delete Storage Disk
az disk list --output table
az disk delete --resource-group ECOMM --name azraybanstg_OsDisk_1_acf662ac54724ef08ebf64d58fff3df8
CREATE VM Using Existing Image Step By Step (DR Script)
## Copy OS disk from Central India to SouthIndia DC storage account
az disk copy-to-vhd --account-name acebialrstorage --destination-blob bialprodOSdisk.vhd --source-resource-group acebial --destination-container acebialrprod --source-disk-name acebialProdOSdisk
## Copy Data Disk From CentralIndia to SouthIndia DC storage account
az disk copy-to-vhd --account-name acebialrstorage --destination-blob bialprodData.vhd --source-resource-group acebial --destination-container acebialrprod --source-disk-name acebialProdData_disk2
### Create disk from Blob
az disk create --resource-group acebialr --name acebialProdOSdiskr --sku Premium_LRS --location southindia --size-gb 128 --source https://acebialrstorage.blob.core.windows.net/acebialrprod/bialprodOSdisk.vhd
az disk create --resource-group acebialr --name acebialProdData_disk2r --sku Premium_LRS --location southindia --size-gb 512 --source https://acebialrstorage.blob.core.windows.net/acebialrprod/bialprodData.vhd
## Run Below Command to create vm in DR DC i.e southindia DC
az vm create --resource-group acebialr --name acebialprod01r --attach-os-disk acebialProdOSdiskr --os-disk-size-gb 128 --os-type linux --attach-data-disks acebialProdData_disk2r --data-disk-sizes-gb 512 --nics acebialprod01rVMNic --size Standard_DS3_v2 --boot-diagnostics-storage acebialrstorage
## Restart the VM
az vm restart --name acebialprod01r --resource-group acebialr
*************************************************************************
### Create VM and attach OS disk created from backup
az vm create --resource-group acebialr --name acebialprod01r --attach-os-disk acebialProdOSdiskr --os-type linux
### Attach data disk which is created from backup and reboot the VM
az vm disk attach --vm-name acebialprod01r --resource-group acebialr --sku Premium_LRS --disk acebialProdData_disk2r --size-gb 512 --caching None
az vm restart --name acebialprod01r --resource-group acebialr
*************************************************************
az vm create --resource-group acebialr --name acebialprod01r --attach-os-disk acebialProdOSdiskr --os-disk-size-gb 128 --os-type linux --attach-data-disks acebialProdData_disk2r --data-disk-sizes-gb 512 --nics acebialprod01rVMNic --vnet-name acebialdb02RVNET --nsg acebialprod01rNSG --public-ip-address acebialprod01rPublicIP --size Standard_DS3_v2
********************************************************
Azure VM's Snapshots
********************************************************
az snapshot create -g bial_magento -n atbialOsdisk --source Bial-fe_OsDisk_1_a74aca969d55464095a54c282c5a5b31
az snapshot show --name atbialOsdisk --resource-group bial_magento --output table
az disk create --resource-group bial_magento --name bialfeOSdisk --sku Premium_LRS --size-gb 31 --source "/subscriptions/a4d11e3d-98db-4857-b50e-6813049bbc66/resourceGroups/bial_magento/providers/Microsoft.Compute/snapshots/atbialOsdisk"
az vm create --resource-group atbial --location centralindia --name atbialtestvm --os-type linux --attach-os-disk atbialOsdisk
az vm disk attach --vm-name atbialtestvm --resource-group atbial --sku Premium_LRS --disk attestbialvmdisk2 --caching None
Resize the vm and reboot
az image copy --source-resource-group acebial --source-object-name bialcentos74 --target-location southindia --target-resource-group "acebialR"
az disk copy-to-vhd --account-name southindiaf5oflf1tizmlnn --destination-blob newdisk --source-resource-group acebial --destination-container snapshots --source-disk-name bialProddbOSdisk
az disk create --resource-group acebialr --name disk1 --sku Premium_LRS --location southindia --size-gb 512 --source https://southindiaf5oflf1tizmlnn.blob.core.windows.net/snapshots/newdisk
Copy disk to Destination Blob
az disk copy-to-vhd --account-name southindiaf5oflf1tizmlnn --destination-blob bialdb01data.vhd --source-resource-group acebial --destination-container snapshots --source-disk-name acebialdb01_OsDisk_1_142cf22dd5914348af705d5d494000f8
Create disk from Blob
az disk create --resource-group acebialr --name disk2 --sku Premium_LRS --location southindia --size-gb 512 --source https://southindiaf5oflf1tizmlnn.blob.core.windows.net/snapshots/bialdb01OSdata.vhd
Create VM from disk created using blob
az vm create --resource-group acebialr --name replicat1 --attach-os-disk disk2 --os-type linux
Create Disk from vhd source
az disk create -g acebialr -n newdisk --source https://southindiaf5oflf1tizmlnn.blob.core.windows.net/snapshots/bialdb01OS.vhd
Azure - VMSS
====================================================
The Azure command-line interface (Azure CLI) is a set of commands used to create and manage Azure resources.
az vmss deleteDelete a VM scale set.
Example of command with optional parametersDelete a VM scale set.
az vmss delete
[--resource-group]
[--subscription]
[--name]
[--vm-scale-set-name]
[--force-deletion]
az vmss get-os-upgrade-historyList the OS upgrades on a VM scale set instance.
Example of command with optional parametersList the OS upgrades on a VM scale set instance.
az vmss get-os-upgrade-history
[--resource-group]
[--subscription]
[--name]
[--vm-scale-set-name]
az vmss list-instancesList all virtual machines in a VM scale sets.
Example of command with optional parametersList all virtual machines in a VM scale sets.
az vmss list-instances
[--resource-group]
[--subscription]
[--name]
[--virtual-machine-scale-set-name]
[--expand]
[--filter]
[--select]
az vmss list-skusList SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU.
Example of command with optional parametersList SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU.
az vmss list-skus
[--resource-group]
[--subscription]
[--name]
[--vm-scale-set-name]
az vmss rolling-upgrade cancelCancel the current virtual machine scale set rolling upgrade.
Example of command with optional parametersCancel the current virtual machine scale set rolling upgrade.
az vmss rolling-upgrade cancel
[--resource-group]
[--subscription]
[--name]
[--vm-scale-set-name]
[--virtual-machine-scale-set-name]
az vmss rolling-upgrade get-latestGet the status of the latest virtual machine scale set rolling upgrade.
Example of command with optional parametersGet the status of the latest virtual machine scale set rolling upgrade.
az vmss rolling-upgrade get-latest
[--resource-group]
[--subscription]
[--name]
[--vm-scale-set-name]
[--virtual-machine-scale-set-name]
az vmss rolling-upgrade startStart a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected.
Example of command with optional parametersStart a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected.
az vmss rolling-upgrade start
[--resource-group]
[--subscription]
[--name]
[--vm-scale-set-name]
[--virtual-machine-scale-set-name]
Azure Load Balancer - Commands -Useful
Example of command with optional parametersList load balancers.
az network lb list
[--resource-group]
[--subscription]
az network lb list-nic List associated load balancer network interfaces.
Example of command with optional parametersList associated load balancer network interfaces.
az network lb list-nic
[--name]
[--resource-group]
[--subscription]
az network lb show Get the details of a load balancer.
Example of command with optional parametersGet the details of a load balancer.
az network lb show
[--name]
[--resource-group]
[--subscription]
[--expand]
az network lb probe list List probes.
Example of command with optional parametersList probes.
az network lb probe list
[--lb-name]
[--resource-group]
[--subscription]
az network lb delete Delete the specified load balancer.
Example of command with optional parameters
az network lb delete
[--name]
[--resource-group]
[--subscription]
az network public-ip list List public IP addresses.
Example of command with optional parametersList all public IPs in a resource group.
az network public-ip list
[--resource-group]
[--subscription]
az network public-ip show Get the details of a public IP address.
Example of command with optional parametersGet information about a public IP resource.
az network public-ip show
[--name]
[--resource-group]
[--subscription]
[--expand]
az network public-ip delete Delete a public IP address.
Example of command with optional parametersDelete a public IP address.
az network public-ip delete [--ids] [--name] [--no-wait {0, 1, f, false, n, no, t, true, y, yes}] [--resource-group] [--subscription]
az network public-ip delete
[--name]
[--resource-group]
[--subscription]
az network public-ip delete [--ids] [--name] [--no-wait {0, 1, f, false, n, no, t, true, y, yes}] [--resource-group] [--subscription]
Comments
Post a Comment