-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource IDs containing spaces can't be consumed by other az commands #12885
Comments
add to S169 |
resource |
Hi @mattcuk, I tried to use the resource name |
Sure.. here's a sample of some of the results.. I've removed the subscription ID + changed some of the names a bit..
Hope this helps. |
@e14mattc Hi, I created some new alerts based on these examples, and the problem still can't be reproduced. |
I'm going to email you direct @zhoxing-ms .. since I'm loathed to paste in production output here. Hope that's ok. |
@e14mattc OK, thanks~ Has the email been sent? I don't seem to have received it |
@zhoxing-ms yes, I sent it at 10am BST yesterday. I wonder if it got stuck in a spam filter due it having a .txt file attachment? The email address I used was your MS account which you have on your GitHub profile. I'll send another with the output in the email itself, rather than an attachment. |
@e14mattc The email has been received, but I still can't reproduce your question. |
I can reproduce the problem currently: there is no problem with this command executing in PowerShell of Windows, it only occurs in the Shell of Linux. |
Couldn't the |
Hi @e14mattc, In fact, this issue is not caused by encoding, but by the subexpression operator When executing But executing If you have a good idea, welcome to communicate with us~ |
How many Azure resources allow a space in the ID, I wonder? Alerts are the only one I've come across so far. Feels like they should maybe restrict this to stop the user entering spaces & potentially running across this issue. If the The code below is how I've worked around the issue, but it's not elegant & it's pretty slow. Is there a better way of dealing with this problem?
|
This requires the service team to see why the resource id allows spaces in some resources.
Yes, this is a solution, and the service team needs to evaluate whether it is breaking change and whether it can be modified~ |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure. |
Yes @navba-MSFT if I run the command in my OP it still fails with the same error. |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
Yes @navba-MSFT if I run the command in my OP it still fails with the same error. |
bump @zhoxing-ms & @msftbot |
I'm bumping this as well. Need to do a FULL sweep of all our resources and az resource list is bringing in the "hidden" resources from the portal, and most of them have spaces. |
same issue when trying to use
|
I have a similar problem. The spaces in the IDs are also a problem here. I have worked around the problem in Bash as follows: az resource list -g example-westeurope-dev-rg --query "[?type=='Microsoft.AlertsManagement/prometheusRuleGroups'].id" --output tsv
#OUTPUTS:
#
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/Prometheus Recommended Pod level Alerts - example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/Prometheus Recommended Cluster level Alerts - example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/NodeRecordingRulesRuleGroup-Win-example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/NodeRecordingRulesRuleGroup-example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/UXRecordingRulesRuleGroup-Win - example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/NodeAndKubernetesRecordingRulesRuleGroup-Win-example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/UXRecordingRulesRuleGroup - example-aks
# /subscriptions/000000-0000-0000-0000-00000000/resourceGroups/example-westeurope-dev-rg/providers/Microsoft.AlertsManagement/prometheusRuleGroups/KubernetesRecordingRulesRuleGroup-example-aks As you can see, there are spaces in the IDs. As shown in the previous posts, this is a problem with the $() operator. Therefore, I tried to work around the problem by explicitly converting the output into an array. This then looks like this. It works for me. RESOURCES_=$(az resource list -g example-westeurope-dev-rg --query "[?type=='Microsoft.AlertsManagement/prometheusRuleGroups'].id" --output tsv | tr "\n" ",")
IFS=',' read -r -a RESOURCES <<< "$RESOURCES_"
az resource show --ids ${RESOURCES[@]} |
I've been trying to use a command to list all the Logic App IDs which have an Alert set up for them. To do this, I'm running 2 commands; az resource list, and az resource show. However, since az resource list returns IDs that contain spaces, az resource show will then fail.
Command Name
az resource show --ids $(az resource list --resource-type Microsoft.Insights/metricAlerts --query [].id --output tsv) --query properties.scopes
Errors:
az resource: error: argument --ids: invalid ResourceId value: 'failed'
To Reproduce:
Create an alert against any Logic App.. make sure the Alert Name has a space in it, like 'logic-app-test-la failed'.
Run the command above.
Expected Behavior
It should really be able to handle the encoding of the spaces so that az resource show can ingest the result of az resource list without having to resort to a Bash script to work round the problem.
Environment Summary
Additional Context
The text was updated successfully, but these errors were encountered: