Azure-cli: BUG: az webapp up - AttributeError: 'NoneType' object has no attribute 'upper'

Created on 5 Nov 2019  Â·  20Comments  Â·  Source: Azure/azure-cli

Describe the bug

I am trying to run the following tutorial:
https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-html

To Reproduce

Follow the steps in the tutorial, there is an error in:
az webapp up --location westeurope --name helloworld12345

Detailed error follows:

webapp helloworld12345 doesn't exist
Creating Resource group 'mcampos_rg_Windows_westeurope' ...
Resource group creation complete
Creating AppServicePlan 'mcampos_asp_Windows_westeurope_0' ...
The command failed with an unexpected error. Here is the traceback:

'NoneType' object has no attribute 'upper'
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 603, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 661, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 652, in _run_job
cmd_copy.exception_handler(ex)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/commands.py", line 55, in _polish_bad_errors
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 631, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 306, in __call__
return self.handler(*args, kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 485, in default_command_handler
return op(
command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 2993, in webapp_up
create_app_service_plan(cmd, rg_name, plan, _is_linux, False, sku, 1 if _is_linux else None, location)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1390, in create_app_service_plan
sku = _normalize_sku(sku)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/utils.py", line 20, in _normalize_sku
sku = sku.upper()
AttributeError: 'NoneType' object has no attribute 'upper'

Please note that az webapp up creates some of the resources and then crashes, so the Azure subscription is left in an inconsistent state.

Expected behavior
Work as before.

Environment summary
Using Azure Shell - azure-cli 2.0.76

Additional context
IMPORTANT: I expect to present this in a customer event on Wednesday 6, this funcionality is part of the existing demo script. I not fixed, I will not be able to show this.

Service Attention Web Apps

Most helpful comment

This issue is marked as close, but I still see the problem as a part of MSLearn course "Host a web application with Azure App Service:
https://docs.microsoft.com/en-us/learn/modules/host-a-web-app-with-azure-app-service/6-exercise-deploy-your-code-to-app-service?pivots=csharp

image

All 20 comments

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI @antcp

dupe of #11080, #11089, #11076

For those facing this issue, please revert to https://azurecliprod.blob.core.windows.net/msi/azure-cli-2.0.75.msi while the WebApp team provides a fix. Let us know if you still face issues.

@achandmsft the Azure Cloud Shell is running 2.0.76 and can't be reverted by the user. What's the ETA on when this will be resolved?

@achandmsft I'm running into this and trying to deploy on WSL/Ubuntu. Just recently installed the Azure CLI per the Azure docs.

How should I revert my WSL Azure CLI?

This issue is marked as close, but I still see the problem as a part of MSLearn course "Host a web application with Azure App Service:
https://docs.microsoft.com/en-us/learn/modules/host-a-web-app-with-azure-app-service/6-exercise-deploy-your-code-to-app-service?pivots=csharp

image

Same here, experience this bug during MSLearn course

This issue should not be closed if the fix hasn't been roll out.

For those of you still facing the issue, try fixing it yourself.

  1. Look at your error message and locate path to file custom.py.
    In most cases it is: /opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py

  2. Apply the fix.

sudo vim /opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py

Go to line 2993 and change to:

create_app_service_plan(cmd, rg_name, plan, _is_linux, False, sku=sku, number_of_workers=1 if _is_linux else None,
                        location=location)

See here: https://github.com/Azure/azure-cli/pull/11104/files

save the file.

  1. rerun your command.

Is there any way to fix this in the Azure Cloud Shell (i.e. with only user permissions)? I seem unable to either apply the fix suggested by htfsik or revert my version of Azure cli.

If not, is there a expected timeframe when this fix will get rolled out to the cloud shell?

How can this not yet have been rolled out?? A show stopper in our project.

this should already rolled out to cloud shell, the full release is on Nov26 in the meantime please use the edge builds https://github.com/Azure/azure-cli#edge-builds

Installing https://github.com/Azure/azure-cli#edge-builds fixed the issue but when I try to update my website ( Angular8-dist) I get:

Could not auto-detect the runtime stack of your app, see 'https://go.microsoft.com/fwlink/?linkid=2109470' for more information.

I have deployed the app the same way with earlier versions of Azure Cli without any problems with the auto-runtime-detect and the detection logic in the link above doesnt match my files aka one index.html plus some *.js ...

From Azure I can get the publishsettings.txt where the only attribute that seem to match my "pure-js" is webSystem="WebSites" and that is no available "runtime-option".

Is this still a bug or have I missed something new in the latest Azure Cli versions ?

First of all thanks for trying the edge builds and confirming this.
Regarding *.html, as a design change based on some feedback we stopped supporting static html & map to stacks that our stacks API returns as valid stacks. Node, Python , ASP.NET & DotNetCore. & this link talks about our detection logic. Please let me know if you have more questions.

I think I have and its kind of funny :)

Currently on my azureaccount I have 3 (client) appservices with "static html & map" which I have been updating using Azure Cli and they call my 1 DotNetCore (server) appservice which I have been updating from my GithHub-branch ... :)

My question is:

Is the best way for me to replace my "static html & map" 3 appservices with 3 "azurestorageblob"s or find another way to upload my "static ht.." ?

My existing "static html & map" 3 appservices use custom domains and https and from reading docs I am worried that "azurestorageblobs" are more limited.

az webapp up internally calls az webapp create to create the app & az webapp deployment source config-zip to deploy the contents to the app. Up creates a zip before doing the deployment when calling the command separately you need to provide the path to the zip file yourself, using the config-zip https://docs.microsoft.com/en-us/cli/azure/webapp/deployment/source?view=azure-cli-latest#az-webapp-deployment-source-config-zip directly would be the solution for now. Let me know if this helps.

this should already rolled out to cloud shell, the full release is on Nov26 in the meantime please use the edge builds https://github.com/Azure/azure-cli#edge-builds

The "Could not auto-detect the runtime stack of your app" error still happens in Cloud Shell AND the latest Edge Build as of 12/3/19.

With the latest change we have made an update where only Python, Node, ASP.NET & .NETCORE stacks are supported & if none these are detected we won't create an empty App anymore. Looks like this is what you are facing.

Problem is everywere

Den ons 4 dec. 2019 kl 19:42 skrev Sisira Panchagnula <
[email protected]>:

With the latest change we have made an update where only Python, Node,
ASP.NET & .NETCORE stacks are supported & if none these are detected we
won't create an empty App anymore. Looks like this is what you are facing.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Azure/azure-cli/issues/11100?email_source=notifications&email_token=AA5UQMS224BTPBNW5U75X4LQW722RA5CNFSM4JI3MPP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF6CGPA#issuecomment-561783612,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA5UQMVXGVLWBOOGPVFCOH3QW722RANCNFSM4JI3MPPQ
.

I ran the following command; (in a cmd window of course)

D:\*-api>az webapp create --name "MyWebApp" --deployment-local-git --resource-group HostRestApiWCorsRG --plan MyAppSvcPlan01

And then got;

usage: az webapp create [-h] 
...
az webapp create: error: 'NoneType' object has no attribute 'location'

Keep in mind that _NOTHING_ in the Usage text mentions either 'NoneType' nor 'location.'

..Then I did this just to show you which az version I'm running.

D:\*-api>az --version
azure-cli                          2.3.0

...

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\*****\.azure\cliextensions'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

...

Your CLI is up-to-date.

FYI

Run the "az web create" command with --debug --verbose in command line arguments. It will show cause of error at the end - either resource group or plan or their combination does not exist, or some error like that.

Was this page helpful?
0 / 5 - 0 ratings