Hello World with Azure Command-Line Interface (CLI)
A quick and simple hello world related to Azure Command Line Interface.
First up, we need to install the tools.
For the sake of simplicity, I always use the command line (running in admin mode) when doing Azure CLI.
C:\Windows\System32>az version
{
"azure-cli": "2.68.0",
"azure-cli-core": "2.68.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {
"azure-devops": "1.0.1",
"interactive": "1.0.0b1"
}
}
Here, make sure that you are already logged in with your microsoft account for Azure, on your windows. This makes the whole thing super easy.
You do this and you will login and see something like this.
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Default Directory'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'bright'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'World Resources Institute'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Training and Development Private Limited'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Active Directory'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Default Directory'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Default Directory'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Vijayasimha Radhakrishnan'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Company'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Bot'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 'Electric Azure Account AD'
No subscriptions found for user@example.com.
Here, you want to login to your portal, and find the exact subscription that you want to work with.
For example, I am going to match the name, Vijayasimha Radhakrishnan in the list of tenants, with that of the tenant name in my portal.
Then, proceed to login to that specific tenant like this.
az login --tenant xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
you will see something like this. Again, you will get a pop up and login will proceed, just fine.
C:\Windows\System32>az login --tenant xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Select the account you want to log in with. For more information on login with Azure CLI, see https://go.microsoft.com/fwlink/?linkid=2271136
Retrieving subscriptions for the selection...
[Tenant and subscription selection]
No Subscription name Subscription ID Tenant
----- ------------------- ------------------------------------ ------------------------------------
[1] * Subscription-1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
The default is marked with an *; the default tenant is 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' and subscription is 'Subscription-1' (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Select a subscription and tenant (Type a number or Enter for no changes): 1
Tenant: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Subscription: Subscription-1 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
After this, go ahead and create a resource group.
az group create --name ResourceGroupFeb32025 --location eastus
C:\Windows\System32>az group list --output table
Name Location Status
--------------------- ---------- ---------
phoblober southindia Succeeded
ResourceGroupFeb32025 eastus Succeeded
note: you may want the exact lettering of the regions you live in. for that, use this. C:\Windows\System32>az account list-locations — output table
I realized, I need a resource group in India. So, I ended up with this.
C:\Windows\System32>az group create --name ResourceGroupFeb32025b --location southindia
{
"id": "/subscriptions/fe7e3475-1ae2-435f-a807-bbd6ba4c7087/resourceGroups/ResourceGroupFeb32025b",
"location": "southindia",
"managedBy": null,
"name": "ResourceGroupFeb32025b",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
Now, let’s create a service plan (which we will need for the web app creation later).
C:\Windows\System32>az appservice plan create --name AppServicePlanFeb32015 --resource-group ResourceGroupFeb32025b --sku F1
Now, the web app.
az webapp create --name WebAppFeb32025 --resource-group ResourceGroupFeb32025b --plan AppServicePlanFeb32015
Grab the URL from the output.
"hostNameSslStates": [
{
"certificateResourceId": null,
"hostType": "Standard",
"ipBasedSslResult": null,
"ipBasedSslState": "NotConfigured",
"name": "webappfeb32025.azurewebsites.net",
"sslState": "Disabled",
"thumbprint": null,
"toUpdate": null,
"toUpdateIpBasedSsl": null,
"virtualIPv6": null,
"virtualIp": null
},
and the web app is ready.
So, that is about it.
To add, I was always apprehensive about using command line and now making some beginner steps. I am still apprehensive about command line, but, it’s nice to at least become familiar with it.
I work as a coding tutor. You can hire me on Upwork, Fiverr and Codementor. You can also book a session on calendly, and visit my website. Also, video tutorials on my YouTube Channel. My Podcast is here.