2021年3月18日星期四

AZ CLI Query Resources with Dashes in name

I am trying to check if a subscription rule exists before attempting to create the rule but I am getting an error suggesting (I am assuming it doesn't like the dashes in the name).

How do I query something with dashes in its name?

ERROR: argument --query: invalid jmespath_type value: '[?name==foo-bar-hello-world]'  

The powershell script I am using is this

$existingRule = az servicebus topic subscription list `  -g 'my-rg' `  --namespace-name 'some-namespace' `  --topic-name 'my-topic' `  --query "[?name==$SubscriptionName]" `  | ConvertFrom-Json  

This is called from a yml pipeline file

  - task: AzureCLI@2      displayName: 'Add Topic Rule'      inputs:        azureSubscription: '$'        scriptType: 'ps'        scriptLocation: 'scriptPath'        scriptPath: '$(Pipeline.Workspace)/Scripts/Create-TopicRule.ps1'        ScriptArguments: >-          -subscriptionName 'foo-bar-hello-world'  
https://stackoverflow.com/questions/66694574/az-cli-query-resources-with-dashes-in-name March 18, 2021 at 11:54PM

没有评论:

发表评论