microsoft / vscode-azureresourcegroups

VS Code extension for managing Azure resources.
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureresourcegroups
MIT License
47 stars 29 forks source link

Cannot group by resource group if I have access to a resource but not its resource group #831

Open vsantele opened 3 months ago

vsantele commented 3 months ago

Hi, I have a "tricky" case that is not well handled by the extension.

In a subscription, I have access to an App Service but not its resource group. So, when I tried to group by resource group, I got the following error:

Internal error: Expected value to be neither null nor undefined: resourceGroup for grouping item

The error is thrown by this line (src/tree/azure/grouping/AzureResourceGroupingManager.ts#164)

It is possible to display the resource group even if we don't have access to it? We will not be able to do action on it, of course.

nturinski commented 3 months ago

Hi @vsantele

It is possible to display the resource group even if we don't have access to it? We will not be able to do action on it, of course.

I just want to clarify, but the scenario is that you want the resource group to still be displayed? Not the resource that's in the resource group?

vsantele commented 3 months ago

Hi @nturinski,

It's more the opposite way. I don't have access to the resource group, only to one resource in it, but I still want to group all my available resources by resource group.

At the moment, if I want to group by resource group, I get an error because the AzureResource of the related resource group of my service app is not in the array allResources passed in groupByResourceGroup

But we can find the name of this resource group. So why not have this RG displayed in the list and not only RG where I got right on it?

Here is a schema to be clear:

- MyRG1 <- I have access
-- MyCosmosDB <- I Have access 
- MyRG2 <- I don't have access
-- MyAppService <- I have access

I cannot group my resources by resource group because of MyRG2.

One way of solving this is to display only a "visual RG" when a user doesn't have access to the parent RG of a resource. This way, we can always group by RG. A "visual RG" will not have all the options inside its context menu like other RG (delete, edit tags, etc) But, GroupingItemFactory.createResourceGroupGroupingItem requires an AzureResource, so I don't think it's possible to do this without further exploration.

alexweininger commented 2 months ago

One way of solving this is to display only a "visual RG" when a user doesn't have access to the parent RG of a resource. This way, we can always group by RG. A "visual RG" will not have all the options inside its context menu like other RG (delete, edit tags, etc)

I agree with the proposed solution.