problem when Creating a web app with Azure command-line interface? - azure

I am newbie with microsoft azure and trying to study and follow the tutorial.
But my problem is, here is my tutorial :
# generate a unique name and store as a shell variable
webappname=mywebapp$RANDOM
# create a resource group
az group create --location westeurope --name myResourceGroup
# create an App Service plan
az appservice plan create --name $webappname --resource-group myResourceGroup --sku FREE
# create a Web App
az webapp create --name $webappname `
--resource-group myResourceGroup `
--plan $webappname
And my problem is, when I coded the code az group create --location westeurope --name myResourceGroup, it always said to me that I must login to azure but I login to azure before that.
And when I searched how to create a web app with azure CLI online, it show me a very different version command like this
https://www.youtube.com/watch?v=qILUM6DyruM
Could you please give me some advise for this problem ? Thank you in advance.

Related

Cannot get Azure container network profile Id

We are actually deploying container to Azure using Azure CLI and the create command as specify the sample documentation below :
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-vnet
In this dosucmentation it is clearly specify from the sample command below that when the container and the Vnet/Subnet gets created, azure create for you a Network Profile Id ( that is need for yaml deplyoement)
az container create --name appcontainer --resource-group myResourceGroup --image mcr.microsoft.com/azuredocs/aci-helloworld --vnet aci-vnet --vnet-address-prefix 10.0.0.0/16 --subnet aci-subnet --subnet-address-prefix 10.0.0.0/24
After the container gets created successfully you are supposed to get Network profile name or ID, which you can obtain using "az network profile list"
Which in fact does not return anything
UPDATE :
I update m Azure CLI to 2.30 in powershell but the result is the same the output of the command return nohing even if container and vnet gets succesfully created
Output result
Thanks for your help
regards
I have tested in my environment.
I deployed a container to a new virtual network using the below command:
az container create --name appcontainer --resource-group myResourceGroup --image mcr.microsoft.com/azuredocs/aci-helloworld --vnet aci-vnet --vnet-address-prefix 10.0.0.0/16 --subnet aci-subnet --subnet-address-prefix 10.0.0.0/24
The container got successfully created.
To get the Network Profile ID, I used the below command:
az network profile list --resource-group myResourceGroup --query [0].id --output tsv
In this way, we can fetch the Network Profile ID
If network profile is not getting created using CLI, try using ARM template
The same happened to me. I solve it using Azure CLI version 2.27.2. Any newer version leaves me with the same problem.
There seems to be a problem with the latest versions of the Azure CLI

How to Get Azure Windows VM plan info?

I'm looking for powershell command to get an Azure Windows VM plan info. I looked up Get-AzVM, but unable to find the required info.
Here's the property on azure portal, that I'm looking for
Please find the below screenshot to get the vm plan information
CLI
az vm show --name myvm --resource-group test --query storageProfile.imageReference.sku
Powershell
Get-AzVM -ResourceGroupName test -Name myvm -Status | select OsName
To get the status of all vms in the resource group :
Get-AzVM -ResourceGroupName test -Status
If this solve your problem then mark this your answer 👍
Use the below query:
az vm show --name myvm --resource-group test --query storageProfile.imageReference.sku

Unable to create the webapp using Azure CLI

I am using the below commands for creating the webapp using Azure CLI but getting the below exception-
Unable to retrieve details of the existing app 'newapp2'. Please check that the app is a part of the current subscription
Command -
az webapp create --name newapp2000 --resource-group staging-grp --plan newappplan2000 --runtime "DOTNETCORE|3.1"
subscription- payasgo
Looking forward for assistance.
A very effective way to check if your commands work or not is going to portal, login with your account, check if your web app exist in your subscription or not.
If you don't want to use portal, you could also use CLI commands. You should check if the session you are using linked to your subscription or not:
az account show --output table
If not, use this command to switch to a different subscription:
az account set --subscription "My Demos"
You could also specify the subscription in the command while creating your web app:
az webapp create --resource-group StorageGroups --subscription "My Demos" \
--name newapp2000 --location eastus --plan newappplan2000 --runtime "DOTNETCORE|3.1"

az aks create - it used to create Service Principal now Managed Service Identity

Update:
A colleague who works for Microsoft said:
Changelog entry for this behaviour change is here: https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/docs-ref-conceptual/release-notes-azure-cli.md#aks-3
I'm following the proper instructions and the documentation must be out of date.
https://learn.microsoft.com/en-us/azure/aks/kubernetes-service-principal
Automatically create and use a service principal.
When you create an AKS cluster in the Azure portal or using the az aks create command, Azure can automatically generate a service principal.
In the following Azure CLI example, a service principal is not specified. In this scenario, the Azure CLI creates a service principal for the AKS cluster. To successfully complete the operation, your Azure account must have the proper rights to create a service principal.
az aks create --name myAKSCluster --resource-group myResourceGroup
This is what happened a few months ago - see Finished service principal creation:
Now when I try I get Add role propagation:
The problem is querying the servicePrincipalProfile.clientId results in msi, I need the guid of the service principal not the Managed Service Identity.
$CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query "servicePrincipalProfile.clientId" --output tsv)
echo $CLIENT_ID
Used to work:
Now its changed:
How do I create the Kubernetes Cluster with a Service Principal as the documentation states and how it used to work?
Repro steps:
https://github.com/MeaningOfLights/AzureTraining/blob/master/Hands-On-Labs-That-Work/80-Kubernetes.md
https://github.com/MeaningOfLights/AzureTraining/blob/master/Hands-On-Labs-That-Work/85-Kubernetes-Deployment.md
For Reference: I got the same and following your link I found that this worked.
az aks show -g aks -n cluster --query identityProfile.kubeletidentity.clientId -o tsv
and this returned the appropriate guide, that I could use for my RBAC assignment
# get the clientId of the cluster
$clientId = (az aks show -g aks -n cluster --query identityProfile.kubeletidentity.clientId -o tsv)
# get the resourceId of the registry
$acrId=(az acr show -g acr -n myacr --query id -o tsv)
# give authority for cluster id to the acr pull
az role assignment create $clientId --role AcrPull --scope $acrId

usage error when creating Webapp in Azure App service

I'm currently following azure official guide on node app deployment in azure app service. LINK
Need to create a web app for the resource group and plan given by the client with below command
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name>
But whenever I do it I get the below error.Any idea how to overcome this error. Thanks
usage error: --runtime | --deployment-container-image-name | --multicontainer-config-type TYPE --multicontainer-config-file FILE
I think I figured that out when u create a linux runtime based plan u have to make sure
--runtime "node|10.10"
parameter is added.That did the work for me

Resources