I want to see all the resource groups in my cluster(s). Is there a way to use az aks to get all the credentials of the cluster(s) without mentioning the names of the resource-group/cluster?
I tried az aks get-credentials, az aks show, az aks list but they all require the resource group name and I don't know it.
Any help is greatly appreciated.
Update:
I have found a way to list all resources in my azure subscription: az resource list.
I can see some resources here that when i try to find using `az
After alot of digging, you can find the list of resource groups using this command - az group list.
Note: its useful to go through the -h of for az to see what it has to offer :)
Related
Normally when you create resources using ARM templates and the azure CLI you can create using:
az deployment group create --resource-group $resourceGroupName --template-file "infra/template.json" --parameters "infra/parameters.json"
Then when I want to delete the resources I can:
az group delete --name $resourceGroupName
However, with Databricks this will create other resource groups as well. Even if you delete the DB resource group, you've still got these other lingering resource groups. I'd like to be able to delete the databricks AND all of the other resources that were created, without having to do extra manual steps.
Any idea of a clean way to do this?
The managed resource group created by Databricks cannot be deleted manually since it was created by the Databricks resource itself. The deny assignment prevents deletion of the managed resource group.
One way to remove resource is to delete the existing workspace following is the example using azure cli
Through AZURE CLI
I have created resource group tvs and databricks tvs for the demo purpose
Delete resource
Use following command in AzureCLI to delete a resource.
Azure CLICopy
az resource delete \
--resource-group tvs\
--name tvs\
--ids *****\
(NOTE : ids is the id of the resource that can be picked from JSON view)
Before deletion
After deletion
Delete resource group
Use following command in AzureCLI to delete the resource group.
Azure CLICopy
az group delete --name tvs
Azure doesn’t currently provide a way to delete multiple resource groups at the same time.
Here’s a method that works for me.
Open Azure Portal
Click on Resource Groups
Select the Resource Groups that you want to delete
Click “Assign tags”
Assign a new tag called “disposable-service”(can be named anything) and tag value to be true
Open Azure Cloud Shell https://shell.azure.com or click on the Azure Shell icon in the Azure Portal toolbar.
the following script into Cloud Shell and hit enter.
az group list --tag disposable-service=true --query "[].[id]" --output tsv
I have two resource groups in Azure, each contains one VMSS (Virtual Machine Scale Sets) and the resources are visible in Azure Portal. The problem is, the following commands return empty output:
az resource list --subscription MySubscription -g vmss-rg
az vmss list --subscription MySubscription -g vmss-rg
az vmss list
However, running az resource list with different resource groups which doesn't have VMSS works fine. I also tested it with different Azure account and subscription, it also worked.
We have tested the same command in our local as suggested by #VenkateshDodda-MT and it works fine. Posting it as an answer to help other community members for the similar issue so that they can find and fix their problem.
To achieve the above requirement we need to install the az powershell module in our local .
Post that run the command in powershell to get the vmss list under our subscription or resource groups:-
az resource list --resource-type "Microsoft.Compute/virtualMachineScaleSets"
OUTPUT:-
To get the VMSS list under particular resource group run the below cmd:
az resource list --resource-type "Microsoft.Compute/virtualMachineScaleSets" -g '<rgName>'
OUTPUT:-
For more information please refer this SO THREAD:Azure PS command returns empty list as suggested by #Olga Osinskaya - MSFT
So I'm new on Azure and got some problems with the CLI on the portal. After creating an AKS service using the UI, I cannot find it in the CLI and get an error message as shown below. Am I missing an obscure setting that filters resources? I can't even find my resource group.
Checked the spelling multiple times, obv.
Also checked this Resource not found..., which is again for very obscure queries, whereas mine is extremely simple.
Any help would be appreciated!
(ResourceGroupNotFound) Resource group 'WebPlatformResource' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'WebPlatformResource' could not be found.
Thank you #Niels Uitterdijk , As discussed i am posting it as an answer to help other community members for the similar issue .
Message: Resource group 'yourresourcegroup' could not be found.
The above error occurs if we have multiple subscriptions, set your subscription first and then try:
To list all subscriptions - az account list --output table
To set your subscription - az account set --subscription "My Demos"
For more information please refer this MS DOC .
I need this to write a bash script. I have a bunch of resource IDs and I need to find the resource groups to which they belong. Is there someway to do this?
The RG name is included in the ID. The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} Part of the resource ID is the resource group name.
Use az resoure show, to get the values of each resource
az resource show --ids /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyWebapp
If you have many ids, you could write a for loop
If you want to write a query you could do JMESPath like this:
az resource list --query [?id=='the-id'].resourceGroup
Or with az resource show --ids
az resource show --ids "the-id" --query properties.actionGroups.groupIds
You still have to loop through the ids though
I wonder if there is a way to use AZ CLI to see all available configuration options for a specific Azure service.
The purpose is to be able to secure that we have configured everything correctly. And to be able to question why certain configuration options has not been configured properly.
You could use az resource show command, in general, you can find the Resource ID in your resource in the portal -> Properties(not exclude some properties of some specific resources cannot be modified, it depends on the specific case).
az resource show --ids <Resource ID of your azure resource>
For example, you could use the command for a web app, the properties are all returned.
az resource show --ids /subscriptions/<subscription-id>/resourceGroups/<grouo-name>/providers/Microsoft.Web/sites/joywebapp1
Besides, if you want to set the properties, you could use az resource update, sample as below.
az resource update --ids $id --set properties.connectionType=Proxy
I am not sure if you want to see all the configuration options for a particular command. Azure CLI has something named Interactive mode which let you to see the available commands and options.