Describe the bug
I get a Bad Request when trying to purge my Premium Verizon CDN endpoint with the following command:
az cdn endpoint purge --profile-name cdn-profile-site5tzanrjnrx7xo --content-paths '/*' --name site5tzanrjnrx7xo --resource-group coderfrontline-site
2019-01-18T03:04:52.5477732Z ERROR: Operation returned an invalid status code 'Bad Request'
2019-01-18T03:04:52.5478467Z Traceback (most recent call last):
2019-01-18T03:04:52.5478947Z File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\knack\cli.py", line 197, in invoke
2019-01-18T03:04:52.5479359Z cmd_result = self.invocation.execute(args)
2019-01-18T03:04:52.5479764Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-cli-core\azure\cli\core\commands\__init__.py", line 366, in execute
2019-01-18T03:04:52.5480434Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-cli-cdn\azure\cli\command_modules\cdn\commands.py", line 23, in _inner_not_found
2019-01-18T03:04:52.5480789Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-cli-core\azure\cli\core\commands\__init__.py", line 343, in execute
2019-01-18T03:04:52.5481114Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-cli-core\azure\cli\core\commands\__init__.py", line 182, in __call__
2019-01-18T03:04:52.5481726Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-cli-core\azure\cli\core\__init__.py", line 436, in default_command_handler
2019-01-18T03:04:52.5482070Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-mgmt-cdn\azure\mgmt\cdn\operations\endpoints_operations.py", line 773, in purge_content
2019-01-18T03:04:52.5482405Z File "C:\Users\trdai\AppData\Local\Temp\pip-install-6nyhv9qe\azure-mgmt-cdn\azure\mgmt\cdn\operations\endpoints_operations.py", line 732, in _purge_content_initial
2019-01-18T03:04:52.5482764Z azure.mgmt.cdn.models.error_response.ErrorResponseException: Operation returned an invalid status code 'Bad Request'
through an Azure CLI release task on Azure DevOps Release pipeline.
To Reproduce
Expected behavior
I ran the same command in the Azure Portal Cloud Shell and it works fine. After a moment it shows
- Running .. until it finishes purging.
Environment summary
Hosted VS2017 agent on Azure DevOps
Additional context
There was no Activity Log on the CDN Endpoint, so I don't believe it ever got to Azure. Hence I suspect the issue lies somewhere between the person (me!) and Azure CLI.
Let me know if this was a fixed issue and the problem lies with outdated Azure DevOps agents. Hosted VS2017 agents are updated monthly so I would expect it's running an up-to-date version of Azure CLI.
Thank you for the great bug report! I'll give this issue a look tomorrow.
I was unable to reproduce the issue with the latest version of Azure CLI.
Would you be able to run the command with --debug, so we can get more information about what is happening in the http request / response?
Ahh I ran it again with debug mode and this is the error that was returned
2019-01-26T20:59:15.0165231Z DEBUG: msrest.http_logger : {
2019-01-26T20:59:15.0165574Z
2019-01-26T20:59:15.0165935Z "error": {
2019-01-26T20:59:15.0166288Z
2019-01-26T20:59:15.0166648Z "code": "BadRequest",
2019-01-26T20:59:15.0167004Z
2019-01-26T20:59:15.0167409Z "message": "Invalid ContentPath \"'/*'\". ContentPath for purge action must be a relative path: either for a single resource \"/path/pic.jpg\" or a wild card \"/path/*\"."
2019-01-26T20:59:15.0167792Z
2019-01-26T20:59:15.0168176Z }
2019-01-26T20:59:15.0168510Z
2019-01-26T20:59:15.0168883Z }
Doesn't explain why running it in Cloud Shell works with the exact same relative path /*
Oh wait now that I read the error message properly, it must be the quotation marks that is causing some issues. I updated the content path to be /* instead of '/*' and then it worked!
The exact same command with '/*' works in Cloud Shell (both Bash and Powershell versions). So... how do I wrap paths that have spaces? ' or "?
I’m wondering if the build agent is Windows based and running in cmd. Perhaps, that would change how the single quotes are interpreted.
I am using the Hosted VS2017 agent so is probably Windows, in which case I
would need to use “/*” instead?
On Sun, 27 Jan 2019 at 10:32 AM, David Justice notifications@github.com
wrote:
I’m wondering if the build agent is Windows based and running in cmd.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Azure/azure-cli/issues/8303#issuecomment-457867776,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIBH-PGooAajuo1Ab3DtVfbUXSgKPbjsks5vHMmEgaJpZM4aI2rH
.
Yes. CMD interprets single quotes as just characters. "/*" should work.
@tjprescott and @zemien are we good with closing this issue? I'm fairly certain this is quote interpretation issue.