2

I'm unable to understand how the documentation is organized. The part I am most confused about is models method in each class, for example: Model class for resource management class

What are these models?

There are multiple documentation pages for a class, and all of these documentation are different: One page for resource management client class (this has the models package), Another page resource management client (this does not)

How is this documentation structured? For example, how do I find a class that deals with autoscaling? Some important links lead to page not founds: this one is linked directly from this (In fact most of the links mentioned in this page lead to 404 - and according to me all of these are very important links with respect to the documentation!). I stumbled upon this while searching for a class that deals with managing resources. I usually try to find classes by going to the documentation page and navigating the documentation tree. Doing a google search and then combing through the search is not ideal. Right now the only way I can find the right class or the method is by going through the samples given and hoping that one of the samples contains my use case. In comparison the AWS python SDK is extremely intuitive to use.

If I am missing some pythonic concepts that are essential to understanding this documentation please tell me me some concepts that I should be aware of.

As a concrete example if I want to list all the autoscale settings for a resource group how do I find the python SDK for the same?

  • 1
    Azure python sdk is based on azure rest api. Azure rest api has different api-version. When azure rest APIs add new features and modfily features, it will publish a new API version. So in normal, please use the latest version. It will have more features or the newest features. – Jim Xu May 17 '21 at 07:11
  • @JimXu Thanks for the tip, referring REST api and then consulting the python sdk makes it much more sense. – tattersail2207 May 17 '21 at 08:03

1 Answers1

0

If you want to list all the autoscale settings for a resource group with pthond sdk, we can use the method MonitorManagementClient.autoscale_settings.list_by_resource_group() in the package azure.mgmt.monitor. For more details, please refer to here

For example

  1. create a service principal and assign azure rabc role to the sp

  2. Install sdk

pip install azure-mgmt-monitor
  1. Code
from azure.identity import ClientSecretCredential

from azure.mgmt.monitor import MonitorManagementClient

CLIENT_ID = 'the appId of the sp'
CLIENT_SECRET = 'the client secret of the sp'
TENANT_ID = ' '
SUBSCRIPTION_ID = ' '
creds = ClientSecretCredential(tenant_id=TENANT_ID,
                               client_id=CLIENT_ID, client_secret=CLIENT_SECRET)

monitor_client = MonitorManagementClient(
    credential=creds, subscription_id=SUBSCRIPTION_ID)
results = monitor_client.autoscale_settings.list_by_resource_group(
    resource_group_name='<group name>')
Jim Xu
  • 21,610
  • 2
  • 19
  • 39
  • @tattersail2207 Since it is useful for you, could you please [mark it as an answer](https://meta.stackexchange.com/a/5235)? It may help more people who have similar issues. – Jim Xu May 17 '21 at 08:28