0% found this document useful (0 votes)
25 views18 pages

Azure CLI 2-1

Uploaded by

hanuman sqlboy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views18 pages

Azure CLI 2-1

Uploaded by

hanuman sqlboy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Azure CLI 2.

0
The Azure CLI 2.0 is a command-line tool providing a great experience for managing Azure resources.
The CLI is designed to make scripting easy, query data, support long-running operations, and more.

Install Azure CLI 2.0 on Windows


For Windows the Azure CLI is installed via an MSI, which gives you access to the CLI
through the Windows Command Prompt (CMD) or PowerShell. When installing for
Windows Subsystem for Linux (WSL), packages are available for your Linux distribution.
See the main install page for the list of supported package managers or how to install
manually under WSL.

The MSI distributable is used for installing, updating, and uninstalling the az command on
Windows.

Download the MSI installer

When the installer asks if it can make changes to your computer, click the "Yes" box.

You can now run the Azure CLI with the az command from either Windows Command
Prompt or PowerShell. PowerShell offers some tab completion features not available from
Windows Command Prompt. To sign in, run the az login command.

1. Run the login command.

** ) az login

1. If the CLI can open your default browser, it will do so and load a sign-in page.
2. Sign in with your account credentials in the browser.

Common commands

This table lists some common commands used in the CLI and links to their reference
documentation.

Resource type Azure CLI command group

Resource group az group

Virtual machines az vm

Storage accounts az storage account

Key Vault az keyvault

Web applications az webapp

SQL databases az sql server


Resource type Azure CLI command group

CosmosDB az cosmosdb

https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest

In this URL you find the commands for Azure CLI .

PS C:\Users\JanardhanCh> az group create --name janarg1 -l westus

"id": "/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups/
janarg1",

"location": "westus",

"managedBy": null,

"name": "janarg1",

"properties": {

"provisioningState": "Succeeded"

},

"tags": null

PS C:\Users\JanardhanCh> az group list

"id": "/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups/
janarg1",

"location": "westus",

"managedBy": null,

"name": "janarg1",

"properties": {

"provisioningState": "Succeeded"
},

"tags": null

PS C:\Users\JanardhanCh> az group list --output table

Name Location Status

------- ---------- ---------

janarg1 westus Succeeded

janarg2 westus Succeeded

janarg3 westus Succeeded

PS C:\Users\JanardhanCh> az group delete --name janarg3 -y

PS C:\Users\JanardhanCh> az group list --output table

Name Location Status

------- ---------- ---------

janarg1 westus Succeeded

janarg2 westus Succeeded

Create a virtual network.

Create a virtual network.

az network vnet create -g MyResourceGroup -n MyVnet

PS C:\Users\JanardhanCh> az network vnet create -g janarg1 -n


janaVnet1

"newVNet": {

"addressSpace": {

"addressPrefixes": [
"10.0.0.0/16"

},

"ddosProtectionPlan": null,

"dhcpOptions": {

"dnsServers": []

},

"enableDdosProtection": false,

"enableVmProtection": false,

"etag": "W/\"0d02f921-2339-4dbe-af8f-9940ff5b78b7\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/janarg1/providers/Microsoft.Network/virtualNetworks/janaVnet1",

"location": "westus",

"name": "janaVnet1",

"provisioningState": "Succeeded",

"resourceGroup": "janarg1",

"resourceGuid": "f51e564d-5652-4f33-bdac-7108adc3e2fe",

"subnets": [],

"tags": {},

"type": "Microsoft.Network/virtualNetworks",

"virtualNetworkPeerings": []

PS C:\Users\JanardhanCh> az network vnet create -g janarg2 -n


janaVnet2

"newVNet": {
"addressSpace": {

"addressPrefixes": [

"10.0.0.0/16"

},

"ddosProtectionPlan": null,

"dhcpOptions": {

"dnsServers": []

},

"enableDdosProtection": false,

"enableVmProtection": false,

"etag": "W/\"de111afd-0a64-4e42-983c-af27f93b5fae\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/janarg2/providers/Microsoft.Network/virtualNetworks/janaVnet2",

"location": "westus",

"name": "janaVnet2",

"provisioningState": "Succeeded",

"resourceGroup": "janarg2",

"resourceGuid": "e12109de-de0f-4993-9a6b-fe270f4cd1e3",

"subnets": [],

"tags": {},

"type": "Microsoft.Network/virtualNetworks",

"virtualNetworkPeerings": []

PS C:\Users\JanardhanCh> az network vnet list

[
{

"addressSpace": {

"addressPrefixes": [

"10.0.0.0/16"

},

"ddosProtectionPlan": null,

"dhcpOptions": {

"dnsServers": []

},

"enableDdosProtection": false,

"enableVmProtection": false,

"etag": "W/\"0d02f921-2339-4dbe-af8f-9940ff5b78b7\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/janarg1/providers/Microsoft.Network/virtualNetworks/janaVnet1",

"location": "westus",

"name": "janaVnet1",

"provisioningState": "Succeeded",

"resourceGroup": "janarg1",

"resourceGuid": "f51e564d-5652-4f33-bdac-7108adc3e2fe",

"subnets": [],

"tags": {},

"type": "Microsoft.Network/virtualNetworks",

"virtualNetworkPeerings": []

},

"addressSpace": {
"addressPrefixes": [

"10.0.0.0/16"

},

"ddosProtectionPlan": null,

"dhcpOptions": {

"dnsServers": []

},

"enableDdosProtection": false,

"enableVmProtection": false,

"etag": "W/\"de111afd-0a64-4e42-983c-af27f93b5fae\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/janarg2/providers/Microsoft.Network/virtualNetworks/janaVnet2",

"location": "westus",

"name": "janaVnet2",

"provisioningState": "Succeeded",

"resourceGroup": "janarg2",

"resourceGuid": "e12109de-de0f-4993-9a6b-fe270f4cd1e3",

"subnets": [],

"tags": {},

"type": "Microsoft.Network/virtualNetworks",

"virtualNetworkPeerings": []

},

"addressSpace": {

"addressPrefixes": [

"10.1.0.0/16"
]

},

"ddosProtectionPlan": null,

"dhcpOptions": null,

"enableDdosProtection": false,

"enableVmProtection": false,

"etag": "W/\"38083ce2-301b-4880-b91b-da7558d4661b\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/Vnet1",

"location": "southindia",

"name": "Vnet1",

"provisioningState": "Succeeded",

"resourceGroup": "testrg",

"resourceGuid": "d825381d-94a0-4956-b125-16a3b7c26c66",

"subnets": [

"addressPrefix": "10.1.0.0/24",

"etag": "W/\"38083ce2-301b-4880-b91b-da7558d4661b\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/Vnet1/subnets/sub1",

"ipConfigurations": [

"etag": null,

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/networkInterfaces/vm1272/
ipConfigurations/ipconfig1",

"name": null,
"privateIpAddress": null,

"privateIpAllocationMethod": null,

"provisioningState": null,

"publicIpAddress": null,

"resourceGroup": "testrg",

"subnet": null

],

"name": "sub1",

"networkSecurityGroup": null,

"provisioningState": "Succeeded",

"resourceGroup": "testrg",

"resourceNavigationLinks": null,

"routeTable": null,

"serviceEndpoints": null,

"type": "Microsoft.Network/virtualNetworks/subnets"

],

"tags": null,

"type": "Microsoft.Network/virtualNetworks",

"virtualNetworkPeerings": [

"allowForwardedTraffic": false,

"allowGatewayTransit": false,

"allowVirtualNetworkAccess": true,

"etag": "W/\"38083ce2-301b-4880-b91b-da7558d4661b\"",
"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/Vnet1/
virtualNetworkPeerings/vnet1tovnet2",

"name": "vnet1tovnet2",

"peeringState": "Connected",

"provisioningState": "Succeeded",

"remoteAddressSpace": {

"addressPrefixes": [

"160.1.0.0/24"

},

"remoteVirtualNetwork": {

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/vnet2",

"resourceGroup": "testrg"

},

"resourceGroup": "testrg",

"type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",

"useRemoteGateways": false

},

"addressSpace": {

"addressPrefixes": [

"160.1.0.0/24"

]
},

"ddosProtectionPlan": null,

"dhcpOptions": null,

"enableDdosProtection": false,

"enableVmProtection": false,

"etag": "W/\"b8fda351-1bfa-4b37-99a3-99306becc8e5\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/vnet2",

"location": "southindia",

"name": "vnet2",

"provisioningState": "Succeeded",

"resourceGroup": "testrg",

"resourceGuid": "e01e3cad-6b4c-4829-8e53-03b488f29ea2",

"subnets": [

"addressPrefix": "160.1.0.0/26",

"etag": "W/\"b8fda351-1bfa-4b37-99a3-99306becc8e5\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/
default",

"ipConfigurations": [

"etag": null,

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/networkInterfaces/vm2627/
ipConfigurations/ipconfig1",

"name": null,
"privateIpAddress": null,

"privateIpAllocationMethod": null,

"provisioningState": null,

"publicIpAddress": null,

"resourceGroup": "testrg",

"subnet": null

],

"name": "default",

"networkSecurityGroup": null,

"provisioningState": "Succeeded",

"resourceGroup": "testrg",

"resourceNavigationLinks": null,

"routeTable": null,

"serviceEndpoints": null,

"type": "Microsoft.Network/virtualNetworks/subnets"

],

"tags": null,

"type": "Microsoft.Network/virtualNetworks",

"virtualNetworkPeerings": [

"allowForwardedTraffic": false,

"allowGatewayTransit": false,

"allowVirtualNetworkAccess": true,

"etag": "W/\"b8fda351-1bfa-4b37-99a3-99306becc8e5\"",
"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/vnet2/
virtualNetworkPeerings/vnet2tovnet1",

"name": "vnet2tovnet1",

"peeringState": "Connected",

"provisioningState": "Succeeded",

"remoteAddressSpace": {

"addressPrefixes": [

"10.1.0.0/16"

},

"remoteVirtualNetwork": {

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/testrg/providers/Microsoft.Network/virtualNetworks/Vnet1",

"resourceGroup": "testrg"

},

"resourceGroup": "testrg",

"type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",

"useRemoteGateways": false

PS C:\Users\JanardhanCh> az network vnet list --output table

EnableDdosProtection EnableVmProtection Location Name


ProvisioningState ResourceGroup ResourceGuid

---------------------- -------------------- ---------- --------- ------------------- ---------------


------------------------------------
False False westus janaVnet1 Succeeded
janarg1 f51e564d-5652-4f33-bdac-7108adc3e2fe

False False westus janaVnet2 Succeeded


janarg2 e12109de-de0f-4993-9a6b-fe270f4cd1e3

False False southindia Vnet1 Succeeded


testrg d825381d-94a0-4956-b125-16a3b7c26c66

False False southindia vnet2 Succeeded


testrg e01e3cad-6b4c-4829-8e53-03b488f29ea2

PS C:\Users\JanardhanCh> az network vnet subnet create -g janarg1 --


vnet-name janaVnet1 -n janaSubnet --address-prefix 1

0.0.0.0/24

"addressPrefix": "10.0.0.0/24",

"etag": "W/\"89f72ddc-f280-4e89-8ad7-8e82017d6398\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/janarg1/providers/Microsoft.Network/virtualNetworks/janaVnet1/subnets/
janaSubnet",

"ipConfigurations": null,

"name": "janaSubnet",

"networkSecurityGroup": null,

"provisioningState": "Succeeded",

"resourceGroup": "janarg1",

"resourceNavigationLinks": null,

"routeTable": null,

"serviceEndpoints": null,

"type": "Microsoft.Network/virtualNetworks/subnets"

}
PS C:\Users\JanardhanCh> az network vnet subnet create -g
janarg2 --vnet-name janaVnet2 -n janaSubnet2 --address-prefix
10.0.0.0/24

"addressPrefix": "10.0.0.0/24",

"etag": "W/\"f1515cfc-1395-4bdc-b064-188d326d917e\"",

"id":
"/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups
/janarg2/providers/Microsoft.Network/virtualNetworks/janaVnet2/subnets/
janaSubnet2",

"ipConfigurations": null,

"name": "janaSubnet2",

"networkSecurityGroup": null,

"provisioningState": "Succeeded",

"resourceGroup": "janarg2",

"resourceNavigationLinks": null,

"routeTable": null,

"serviceEndpoints": null,

"type": "Microsoft.Network/virtualNetworks/subnets"

PS C:\Users\JanardhanCh> az network vnet subnet list -g janarg1


--vnet-name janavnet1

"addressPrefix": "10.0.0.0/24",

"etag": "W/\"89f72ddc-f280-4e89-8ad7-8e82017d6398\"",

"id": "/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups/
janarg1/providers/Microsoft.Network/virtualNetworks/janaVnet1/subnets/janaSubnet",

"ipConfigurations": null,

"name": "janaSubnet",

"networkSecurityGroup": null,
"provisioningState": "Succeeded",

"resourceGroup": "janarg1",

"resourceNavigationLinks": null,

"routeTable": null,

"serviceEndpoints": null,

"type": "Microsoft.Network/virtualNetworks/subnets"

PS C:\Users\JanardhanCh> az network vnet subnet list -g janarg1


--vnet-name janavnet1 --output table

AddressPrefix Name ProvisioningState ResourceGroup

--------------- ---------- ------------------- ---------------

10.0.0.0/24 janaSubnet Succeeded janarg1

PS C:\Users\JanardhanCh> az network vnet subnet list -g janarg2


--vnet-name janavnet2 --output table
AddressPrefix Name ProvisioningState ResourceGroup

--------------- ----------- ------------------- ---------------

10.0.0.0/24 janaSubnet2 Succeeded janarg2

PS C:\Users\JanardhanCh> az network vnet subnet list -g janarg1 --vnet-name janavnet1

"addressPrefix": "10.0.0.0/24",

"etag": "W/\"89f72ddc-f280-4e89-8ad7-8e82017d6398\"",

"id": "/subscriptions/eca470dc-8964-4af9-83be-d2029767b9b8/resourceGroups/janarg1/providers/Microsoft.Network/
virtualNetworks/janaVnet1/subnets/janaSubnet",

"ipConfigurations": null,

"name": "janaSubnet",

"networkSecurityGroup": null,

"provisioningState": "Succeeded",

"resourceGroup": "janarg1",
"resourceNavigationLinks": null,

"routeTable": null,

"serviceEndpoints": null,

"type": "Microsoft.Network/virtualNetworks/subnets"

PS C:\Users\JanardhanCh> az network vnet subnet list -g janarg1 --vnet-name


janavnet1 --output table

AddressPrefix Name ProvisioningState ResourceGroup

--------------- ---------- ------------------- ---------------

10.0.0.0/24 janaSubnet Succeeded janarg1

You might also like