Unable to create the webapp using Azure CLI - azure-web-app-service

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"

Related

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

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.

microsoft.containerregistry/registries' could not be found in subscription

I am geeting the error while I try to attach the Azure Container Registry to the AKS using Visual studio
syntax:
az aks update --name $CLUSTER_NAME --resource-group $RESOURCE_GROUP --attach-acr $ACR_NAME
Error:
microsoft.containerregistry/registries' could not be found in subscription
I have logged into the correct subscription and also set the correct subscription
az login --tenant $TENANT_ID
az account set --subscription $SUBSCRIPTION
az acr list also shows me the acr that is created
any possible solution for this?
Tested in my environment it is working fine for me, The error you are getting is due to you are looking into wrong subscription. When you use the CLI command az login then you log in with a default subscription. For you, it seems the "Some Other susbscription" is the default. You should check if your registry is in the current subscription. If not, you should set that subscription as the current subscription through the CLI command:
az account set --subscription subscription_id
Now would suggest you to check if the registry exists in current subscription with the CLI command:
az acr show -n acr_name
Also, you can set the subscription in the login time with the parameter --subscription through the CLI command az login.
Reference : az acr - Unable to find repository in case of multiple subscription on single account

How to change plan when deploing the app?

I had created my own subscription for Azure App Service. Then I had deployed my app (used CLI)
After that I remove the app, the resource group as well as subscription itself.
Now I got corporate subscription, create App Service via Azure UI and now trying to deploy my app to there.
When I use command
az webapp up --name MyAppName
i get message: The webapp 'MyAppName' exists in ResourceGroup 'MyCorporateGroup' and does not match the value entered 'MyPrivategroup '. Please re-run command with the correct parameters.
When I use command:
az webapp up --name MyAppName --resource-group MyCorporateGroup --subscription MyCorporateSubscription
I get: The plan name entered 'MyCorporateGroup_0' does not match the plan name that the webapp is hosted in 'MyCorporatePlanForAppService'.Please check if you have configured defaults for plan name and re-run command.
And when I use command:
az webapp up --name MyAppName --resource-group MyCorporateGroup --subscription MyCorporateSubscription -p MyCorporatePlanForAppService
i get message: Creating AppServicePlan MyCorporatePlanForAppService ...
(InvalidResourceLocation) The resource 'MyCorporatePlanForAppService' already exists in location 'germanywestcentral' in resource group 'MyCorporateGroup'. A resource with the same name cannot be created in location 'centralus'. Please select a new resource name.
Does anyone know how can i deploy my app to the corporate app service?
Thanks
The problem has been resolved when I remove .AZURE folder from my local machine. And then rebuild the app.
It seems to me you're not changing from one context to another. Try executing the following command before trying to update the web app in your corporate subscription:
az account set -s <corporate-subscription-name-or-id>

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

Enterprise bot msbot clone services command hangs

I've created a bot from the VS Enterprise bot template. When I run the "msbot clone services" command, it hangs in the middle of the script after creating the Azure Search service. There are no apparent errors running --verbose but the script is clearly hung and only installs half of the services in Azure.
Azure shows all the steps so far a successful. Can anyone suggest how to get more logging information than using the --verbose flag?
D:\Dev\sobot181214\sobot181214 msbot clone services --name "sobot181214" --luisAuthoringKey "**REDACTED**" --folder "DeploymentScripts\en" --location "westus" --verbose
Checking az botservice version
az -v
checking dotnet requirement
dotnet --version
Fetching subscription account
az account show
The following services will be created by this operation:
Service Location SKU Resource Group
Azure App Site Plan westus S1 sobot181214
Azure AppInsights Service West US 2 F0 sobot181214
Azure Blob Storage Service westus Standard_LRS sobot181214
Azure Bot Service Registration Global sobot181214
Azure CosmosDB Service westus 1 write region sobot181214
Azure LUIS Cognitive Service westus S0 sobot181214
Azure LUIS Cognitive Service westus S0 sobot181214
(Dispatch)
Azure QnA Maker Service westus S0 sobot181214
Azure Search Service westus Standard sobot181214
Azure WebApp Service (Bot) westus sobot181214
Azure WebApp Service (QnA) westus sobot181214
Resources will be created in subscription: Pay-As-You-Go Dev/Test (**REDACTED**)
Would you like to perform this operation? [y/n]y
Creating Azure group [sobot181214]
az group create -g sobot181214 -l westus --subscription **REDACTED**
Creating Azure Bot Service [sobot181214]
az bot create -g sobot181214 --name sobot181214 --kind webapp --location westus --insights-location "West US 2" --subscription **REDACTED** --version v4 -- lang CSharp --verbose
[az bot] INFO: Microsoft application id not passed as a parameter. Provisioning a new Microsoft application.
(Please be patient, this may take several minutes)
[az bot] To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code xxxxxxx to authenticate.
Fetching bot extended information [sobot181214]
az bot show -g sobot181214 -n sobot181214 --subscription **REDACTED**
Fetching co-created resources [sobot181214]
az resource list -g sobot181214 --subscription **REDACTED**
Fetching bot website appsettings [sobot181214]
az webapp config appsettings list -g sobot181214 -n sobot1812141nay --subscription **REDACTED**
Creating LUIS Cognitive Service [sobot181214-LUIS]
az cognitiveservices account create -g sobot181214 --kind LUIS -n "sobot181214-LUIS" --location westus --sku S0 --yes --subscription **REDACTED**
Fetching LUIS Keys [sobot181214-LUIS]
az cognitiveservices account keys list -g sobot181214 -n "sobot181214-LUIS" --subscription **REDACTED**
Creating site plan [sobot181214]
az appservice plan create -g sobot181214 --sku s1 --name sobot181214 --subscription **REDACTED**
Creating Azure Search Service [sobot181214-search]
az search service create -g sobot181214 -n "sobot181214-search" --location westus --sku standard --subscription **REDACTED**
based on the code snippet and output log that you have provided, I see that it was successfully executing various commands (i.e., creating group, creating bot, showing bot, listing resource, listing webapp config appsettings, creating cognitiveservices account, listing cognitiveservices account keys, creating appservice plan respectively) until it has reached the step to create search service. But I think there was some issue while creation of appservice plan step or even while creation of bot step. So just to understand the issue better, by chance if you have appservice plan named ‘sobot181214’ still available and bot webapp named ‘sobot181214’ still available then can you check if they are properly created or are they in a kind of corrupted or unstable state ?
Also the catch point is as per this (https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-enterprise-template-deployment?view=azure-bot-service-4.0) link, it states that some users might experience issues if ‘--appId’ argument is not provided while running the command ‘msbot clone services’. So can you browse to https://apps.dev.microsoft.com and manually create a new application retrieving the ApplicationID and Password/Secret. And then run the ‘msbot clone services’ command along with the arguments ‘--appId’ and --appSecret’ passing the values you have just retrieved and let me know the outcome. Also ensure that you wrap the secret with quotes to prevent parsing issues, e.g: --appSecret "YOUR_SECRET".
On the other hand, if you are interested to debug the current issue in detail, you may try to update all the ‘az’ commands in the script ‘C:\Users\USERNAME\AppData\Roaming\npm\node_modules\msbot\bin\msbot-clone-services.js’ appended at the end with ‘ --debug’ parameter which would increase the logging verbosity to show all debug logs while executing ‘msbot clone services’ command. But in some cases, updating ‘msbot-clone-services.js’ file corrupts the msbot related packages. In case if that happens then you may uninstall and re-install msbot and related packages by running the command ‘npm install -g ludown luis-apis qnamaker botdispatch msbot chatdown’ as instructed in this (https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-enterprise-template-deployment?view=azure-bot-service-4.0) link.
Hope this helps!!

Resources