Home > Net >  How to access Azure resources through powershell?
How to access Azure resources through powershell?

Time:09-21

Just want to know how can I get the service buses in the portal through powershell

I was able to access the app insights through this piece of script

az monitor  app-insights component show | ConvertFrom-Json

Now I wish to access the service bus , app service and app service plans as well through powershell

I was using this

az monitor  servicebus component show | ConvertFrom-Json

for service bus but it is not working.

CodePudding user response:

You are using Azure CLI there, not the PowerShell modules. If you want to list / show the details around the following services, then you need to use the corresponding Azure CLI commands:

  1. ServiceBus

    az servicebus namespace show --resource-group myresourcegroup --name mynamespace

    Reference: https://learn.microsoft.com/en-us/cli/azure/servicebus/namespace?view=azure-cli-latest#az-servicebus-namespace-show

  2. App Service

    az webapp show --name MyWebapp --resource-group MyResourceGroup

    Reference: https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-show

  3. App Service Plans

    az appservice plan show --name MyAppServicePlan --resource-group MyResourceGroup

    Reference: https://learn.microsoft.com/en-us/cli/azure/appservice/plan?view=azure-cli-latest#az-appservice-plan-show

Here is the full CLI reference: https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest

CodePudding user response:

To get service bus namespace list in your current subscription, you use below command:

az servicebus namespace list

enter image description here

To get the service bus queue list you below command:

az servicebus queue list --resource-group myresourcegroup --namespace-name mynamespace

If you want for topic, keep topic in place of queue in above command.

If you want to get app service plans use the below command:

az appservice plan list

Alternatively, you can use azure resource graph query like below for servicebus:

resources
| where type =~ 'microsoft.servicebus/namespaces'

enter image description here

You can use azure resource graph query like below to get app services:

resources
| where type == 'microsoft.web/sites'

enter image description here

References taken from:

Edit:

Yes if you want apim use below query:

resources
| where type == "microsoft.apimanagement/service"

enter image description here

Get apim Using cli :

az apim api list --resource-group myresourcegroup --service-name
   myservice
  • Related