Azure – Resource Providers with PowerShell and CLI

Hello Everybody,

Today we will continue with our last post Azure – Resource and Resource group and discuss about one more useful component of Microsoft Azure before proceed with Azure Resource Manager(ARM).

The resources in our resource groups are created and managed by Resource Providers. Each resource provider knows, how to manage and configure their resource.

Architecturally, this is a big change in Azure, because it means that new resource types can be developed, Deploy and exposed through a single management pane (ie: ARM) rather than having resource specific API’s which is the case for the old service management API’s.

There are different approaches available to deals with Azure Resource provider. Lets go through one by one. Today in this blog we will go with PowerShell and Azure CLI .In our next article, we will describe, how to work with Azure Resource Provider through Azure Portal.

  1. Power Shell:
    • View all resource providers in Azure :
      Using the following command we can get all resource providers in Azure for my subscription.

      Get all information of Resource Providers
      Figure 1: Azure – Get all information of Resource Providers

      Using the following command we can get all resource providers in Azure with specific information for my subscription like registration status.

      Get All Resource Providers
      Figure 2: Azure – Get All Resource Providers

    • Register a resource provider:
      Using the above command, we can check, if our required Resource Provider is registered or it required a registration. If our required Resource Provider not registered yet we can register it using following command. But we must have sufficient rights to register resource provider. The scope for registration is always the subscription. Our subscription must have permission to register the Resource Provider.We can see in the above figure, resource provider Microsoft.Batch has not registered yet. We can register that using the following command and the respected result can be seen in the following figure.

      Registering a Resource Provider
      Figure 3: Azure – Registering a Resource Provider

      After successfully register the provider, lets check the status of the resource provider using following powershell.

      Registered Resource Provider
      Figure 4: Azure – Registered Resource Provider

    • Get API versions of resource type:
      In this way we can use powershell to interact with resource provider. we can get much more required information like, resource types for a resource provider , API versions of resource type. following are few powershell command for the above requirement.

    • Get all supported locations for a resource type:One more important point to note is, resource manager is supported in all regions, but the resources we want to deploy might not be supported in all regions. Addition to this, there may be limitations on our subscription that prevent us from using some regions that support the resource. So we can check the supported location for a resource type using following powershell command.

      Supported location to a resource
      Figure 4: Azure – Supported location to a resource

  2. Azure CLI:
    As we said earlier in this blog, there are different way to work with Azure Resource Provider as we did with powershell. Now we will use Azure CLI to achieve same goal. In our one of last blog we have discussed how to start Working with Azure CLI.

    • View all resource providers in Azure :

      As we can see in the following figure, we have registered teh Microsoft.Batch resource provider in our last demo with powershell.
      Get all Resource Provider using Azure CLI
      Figure 6: Azure – Get all Resource Provider using Azure CLI
    • Register a resource provider:


      As we can see in the above figure, we have Microsoft.AlertsManagement resource provider, which is not registered yet. So lets proceed with this provider and register it, as in shown in the above CLI command and the result in the following figure.

      New Resource Provider resistered
      Figure 7: Azure – New Resource Provider resistered

    • Get API versions of resource type:

      New Resource Provider resistered
      Figure 8: Azure – Version information

    • Get Supported locations information for a resource:

      With the above CLI command, we have tried to find, if “Microsoft.AlertsManagement” have any locations for its any resource type. But unfortunatly, we don’t find any value there, as we can see in the following image. So here we are, using “Microsoft.Batch” provider for our demo purpose .

      No locations for the resource type
      Figure 9: Azure – No locations for the resource type

       Get supported location to a resourcetype
      Figure 10: Azure – Get Supported locations for a resource

We will come with one new blog, where we will describe how to communicate with Resource Provider through Azure Portal.

Hope this blog gives you a basic understanding on Azure Resource Provider.

Thanks for reading 🙂

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles.

Advertisements

Comments

2 comments on “Azure – Resource Providers with PowerShell and CLI”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.