-
Notifications
You must be signed in to change notification settings - Fork 3.4k
az CLI returns bad request when using bash variable #28159
Copy link
Copy link
Open
Labels
Auto-AssignAuto assign by botAuto assign by botAuto-ResolveAuto resolve by botAuto resolve by botRecovery Services Backupaz backupaz backupService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.act-observability-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Metadata
Metadata
Assignees
Labels
Auto-AssignAuto assign by botAuto assign by botAuto-ResolveAuto resolve by botAuto resolve by botRecovery Services Backupaz backupaz backupService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.act-observability-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Describe the bug
I have this Az cli command that enables backup for a VM that I'd like to use with a script:
i get this error:
Operation returned an invalid status 'Bad Request'this is the official Azure documentation i followed :
az backup protection enable-for-vm --resource-group myResourceGroup --vault-name myRecoveryServicesVault --vm $(az vm show -g VMResourceGroup -n MyVm --query id | tr -d '"') --policy-name DefaultPolicywhen I run the same command substituting the $getID with its value (echo $getID and then copy paste the value into the command) it works perfectly:
Related command
az backup protection enable-for-vm
Errors
Operation returned an invalid status 'Bad Request'Issue script & Debug output
raceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 663, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 726, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 718, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/_exception_handler.py", line 10, in backup_exception_handler
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Bad Request'
cli.azure.cli.core.azclierror: Operation returned an invalid status 'Bad Request'
az_command_data_logger: Operation returned an invalid status 'Bad Request'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000002031E5E0700>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 1.359 seconds (init: 0.561, invoke: 0.798)
Expected behavior
VM backup should be enabled for the VM
Environment Summary
azure-cli 2.53.0 *
core 2.53.0 *
telemetry 1.1.0
Dependencies:
msal 1.24.0b2
azure-mgmt-resource 23.1.0b2
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\HENDAOUIMohamedAli.azure\cliextensions'
Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
Legal docs and information: aka.ms/AzureCliLegal
Additional context
No response