Install MSFT CDM Python SDK as part of a Docker build

Jared Hanson (US) 1 Reputation point
2022-02-14T19:39:30.607+00:00

I'm just looking for info into how to install the CDM python SDK in a docker build As of right now, we just have the whole Python SDK folder stored in the Repo with the rest of our code. It would be nice if we could just install it in a docker image. Thanks

Community Center Not monitored
{count} votes

1 answer

Sort by: Most helpful
  1. Monalla-MSFT 13,071 Reputation points Moderator
    2022-02-15T02:11:05.173+00:00

    Hello @Jared Hanson (US) - Welcome to Microsoft Q&A and thanks for reaching out.

    In order to install the CDM python SDK in a docker build:

    You can find it on : PyPi .

    and you can install it using pip install azure. It's open, it's developed on GitHub and it's available on PyPi.

    If you would like to run it on Python 3.6, please see the below code. it will be compatible with other versions also, like 3.5, 2.4 and 3.3

    from azure.common.credentials import ServicePrincipalCredentials  
    from azure.mgmt.resource import ResourceManagementClient  
    import os  
    import keyring.backend  
    from keyrings.alt.file import PlaintextKeyring  
      
    keyring.set_keyring(PlaintextKeyring())  
      
    TENANT_ID = os.getenv('TENANT_ID')  
    CLIENT = os.getenv('CLIENT')  
    KEY = os.getenv('KEY')  
    SUBSCRIPTION = os.getenv('SUBSCRIPTION')  
      
      
    credentials = ServicePrincipalCredentials(  
        client_id=CLIENT,  
        secret=KEY,  
        tenant=TENANT_ID  
    )  
      
    client = ResourceManagementClient(credentials, SUBSCRIPTION)  
      
    rgs = client.resource_groups.list()  
      
    for rg in rgs:  
        print(rg.name)  
    

    For more information regarding the same, please take a look at the below document: azure-sdk-for-python-in-docker-container

    Hope this helps.

    ------------------------------------------------------------------

    If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the same so it can be beneficial to the community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.