[PowerShell] Get-FinOpsHub â Get all resources based on name
đ Scenario
As a hub admin, I need to get metadata about a hub instance with all dependant resources in order to manage delete all resources
đ Solution
Update Get-FinOpsHub command to get all related resources.
Synopsis, syntax, description, and parameters stay the same. The only thing that changes is the output.
âšī¸ Additional info
Use the following code to get any addtional resources that were not identified via the tag:
$kv = $hub.Resources | Where-Object ResourceType -eq "Microsoft.KeyVault/vaults"
$uniqueId = $kv[0].Substring($kv[0].LastIndexOf("-") + 1)
$resources = Get-AzResource -ResourceGroupName $ResourceGroup | Where-Object Name -like "*$uniqueId*"
The output object should look this:
{
// ID is added as a cm-resource-parent tag to all deployed resources as part of the bicep code
Id: "/subscriptions/.../resourceGroups/.../providers/Microsoft.Cloud/hubs/...",
// Type and name can be parsed out of the ID
Type: "Microsoft.Cloud/hubs",
Name: "...",
// Location would be pulled from the resources
Location: "...",
// Version pulled from settings.json
Version: "0.0.1",
// Resources determined at runtime via tags or with the unique deployment id in the name
Resources: [
{ ... },
{ ... },
{ ... },
...
],
}
đââī¸ Ask for the community
We could use your help:
- Please vote this issue up (đ) to prioritize it.
- Leave comments to help us solidify the vision.
@aromano2 wrote a handy module to extract the unique identifier from all the resources as part of the hub. I've implemented this in the remove-finopshub module, so this is no longer required for delete.
@flanakin i just sync with @Springstone - just to confirm that we are doing this?