"az storage message get" crashes (Ubuntu 20.04 LTS, az-cli 2.36.0-1~focal)
See original GitHub issueDescribe the bug
az storage queue get fails
To Reproduce
- start azurite (or connect to a azure hosted storage account)
- set AZURE_STORAGE_CONNECTION_STRING
- az storage queue create --name egress-test
- az storage message get -q “egress-test”
Expected behavior
This should not crash.
❯ az storage message get -q "egress-test"
Command group 'storage message' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
The command failed with an unexpected error. Here is the traceback:
End of paging
Traceback (most recent call last):
File "/opt/az/lib/python3.8/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 658, in execute
raise ex
File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 713, in _run_job
return cmd_copy.exception_handler(ex)
File "/opt/az/lib/python3.8/site-packages/azure/cli/command_modules/storage/__init__.py", line 409, in new_handler
first(ex)
File "/opt/az/lib/python3.8/site-packages/azure/cli/command_modules/storage/__init__.py", line 408, in new_handler
raise ex
File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/opt/az/lib/python3.8/site-packages/azure/cli/command_modules/storage/operations/queue.py", line 86, in receive_messages
return list(next(page_iter))
File "/opt/az/lib/python3.8/site-packages/azure/core/paging.py", line 84, in __next__
self.continuation_token, self._current_page = self._extract_data(self._response)
File "/opt/az/lib/python3.8/site-packages/azure/multiapi/storagev2/queue/v2018_03_28/_models.py", line 288, in _extract_data_cb
raise StopIteration("End of paging")
StopIteration: End of paging
To open an issue, please run: 'az feedback'
Environment summary
ubuntu 20.04 container with azure-cli installed from ms repo.
ii azure-cli 2.36.0-1~focal all Azure CLI
Issue Analytics
- State:
- Created a year ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
az storage message | Microsoft Learn
You can find each service primary endpoint with az storage account show . Environment variable: AZURE_STORAGE_SERVICE_ENDPOINT. --sas-token. A Shared Access ...
Read more >Ubuntu 20.04 Crashing every 1-2 days
I ran the command journalctl | grep error after the last crash and these are the only error messages from the day it...
Read more >az storage copy crashes: ValidationError: local variable ...
I have noticed that running the recently updated azure cli (2.13.0) locally from command line works and does not encounter the original error...
Read more >Find Ubuntu Images on Microsoft Azure - Server
Users can find the latest Ubuntu images in the Azure Marketplace when ... to find the latest image for Ubuntu 20.04. LTS: $...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @evelyn-ys Yishi / @navba-MSFT, I don’t believe this to be an SDK issue but rather an issue with how the CLI is calling the Track2
receive_messages
API. Here is the code snippet I think CLI is using:https://github.com/Azure/azure-cli/blob/cc0d149c1d3bea7ffbac12f8e97e0286cddfaa23/src/azure-cli/azure/cli/command_modules/storage/operations/queue.py#L84-L86
When using
by_page()
and then callingnext
on the resulting Iterator, it is expected that the Iterator will throw aStopIteration
exception if there is not a next item, like is the case when the Queue is empty. There are a couple of immediate ways around this that I can think of: Catching theStopIteration
exception or using the default value param ofnext()
.Either of those should solve the Issue at hand but I’m also curious what the CLI actually is trying to do? Is this intention to receive a certain number of messages? Is that user settable?
receive_message
singular from the SDKmessages_per_page
or something alike? There is some odd behavior withreceive_messages
in this case where it will continually get messages unless you ask for each page viaby_page()
so the approach is correct here.max_messages
parameter to this function (in our next release) where you can specify a maximum number of messages so it does not continually grab messages from the Queue. In that case you would not need to useby_page()
at all and could just do something like below, which would also eliminate theStopIteration
exception on an empty Queue. (Also see the SDK sample)Note: An optimization to the above would be to also set
messages_per_page
since that controls how many messages the server returns in a single request. If not set, the default is 1.Sorry for the long message but hopefully that clears up the Issue and provides some potential fixes. Please ping me offline if you need more help. Thanks!
Thanks @jalauzon-msft . As per your above suggestion, I have done the necessary changes and filed the below PR. Currently it is pending on review.
PR: https://github.com/Azure/azure-cli/pull/22335