azure-cli: webapp:'NoneType' object has no attribute 'location' error when setting up Github deployment
Describe the bug When setting up Github deployment, the following command returns an error for one of my resource groups.
'NoneType' object has no attribute 'location'
Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/knack/cli.py", line 197, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 344, in execute
cmd.exception_handler(ex)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/command_modules/appservice/commands.py", line 51, in _polish_bad_errors
raise ex
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 319, in execute
result = cmd(params)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 180, in __call__
return super(AzCliCommand, self).__call__(*args, **kwargs)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/knack/commands.py", line 109, in __call__
return self.handler(*args, **kwargs)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 420, in default_command_handler
result = op(**command_args)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 703, in config_source_control
location = _get_location_from_webapp(client, resource_group_name, name)
File "/usr/local/Cellar/azure-cli/2.0.31/libexec/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1005, in _get_location_from_webapp
return webapp.location
AttributeError: 'NoneType' object has no attribute 'location'
If I create a new resource group, everything seems to work fine. It’s just this one that is a problem.
To Reproduce Execute the command to setup Github deployment from the CLI
az webapp deployment source config --name MyAppName --resource-group myResourceGroup
--repo-url MyRepoURL
Expected behavior The Github deployment should be enabled on the site.
Environment summary Installed via Home Brew CLI Version: 2.0.31 Shell Type: Bash / zsh
Additional context
The name of the resource group is MyFirstAppResourceGroup
. I’m not sure if it’s safe to leave my Subscription ID here in plain text, but if that’s OK. I can include that as well.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (4 by maintainers)
I don’t want to have to provision anything using the portal. I want Infrastructure as Code. I’m new to Azure, and I’m finding much more difficult than either AWS or GCP to do everything programmatically.
Whoever reading these issues, could you please write meaningful error messages?
If there is an error don’t just print it, add a reason why it choked next to it so we don’t need to debug the simplest command such as
az webapp create
. It looks like error comes from Python code, just putHow difficult is this to write? Why am I continuously googling your cryptic error messages? Why is this issue closed without fixing this error?
Happens to me as well. In my scenario, I create a webapp, delete it, and then created an identical one with a different name, and I get this error.
Last time I had this issue, it was because I was specifying the wrong resource group. az webapp create --resource-group $resourceGroup --plan $hostingPlan --name $applicationName --deployment-container-image-name $dockerCustomImageName
Make sure the the resource group is the one in which your service plan is created.
I got this error message: " az webapp create: error: ‘NoneType’ object has no attribute ‘location’ " When running:
This solved it for me:
It works for me now. Please re-verify
Using the portal I’m able to create a webapp manually referencing an already created service plan in a different resource group. Using az client I’m expecting the same… but I expent a lot of time to guess how to do it. Finally I tried -p {planresourceId} instead of -p {planresourcename} when creating web app and worked. I think this should be fixed to avoid people wasting time guessing things. Documentation says that you can use name or id in plan parameter… name seems that only works if webapp belongs to same resource group than plan.
I’m expending more time dealing with this kind of errors than writing my scripts wich is frustrating. I would expect a fix, a proper response message or a clear explanation of this “limitations” in az docs, but seems easier to close the issue.
Just in case it helps, I got this error when the appservice plan didnt exist.
This is what was happening to me as well: I created a webapp, there was a problem in my docker-compose.yml, so I deleted the webapp and created it again using the exact same “az webapp create” command I used the first time, and now I get NoneType object has no attribute ‘location’.
I then re-ran the “az webapp create” with --debug, and it’s telling me it Cannot find ServerFarm with name xxx. I think a server farm might be an app service plan. I definitely have an app service plan with the given name.
I was able to fix it: Even though I had an App Service Plan with the name I was using, when I went in to look at that plan it was in a zombie state: The status of the plan in the portal showed “—”, and it did not show the CPU/Memory charts. Also I could not delete this app service plan in the portal normally; I had to delete the service plan by going to the resource group and deleting it from there.
I deleted and re-created my app service plan, and then this started working. I had done a “az webapp delete” a bit earlier, thinking it would delete my web app and not the service plan. Something that happened somewhere made the app service plan invalid, but still sort of showing up.
The name of the app is MyFirstApp-burke
I should note that if I delete that Resource Group and then wait long enough, I can recreate it without any problems. It looks like this is only an issue when you delete a resource group (with a service plan and webapp in it) and then immediately recreate it.