Reputation: 249
I am new to azure and just stared learning, my aim is to get instance information using azure cli and python sdk, I am learning from official docs https://learn.microsoft.com/en-us/python/api/overview/azure/containerinstance?view=azure-python
I am trying to authenticate and get container info but script is not working, I have followed step 1 and 2. please help and if there is any other easy way to learn inform me.
here is code that i am using
from os import getenv
from azure.common.client_factory import get_client_from_auth_file
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from azure.mgmt.resource.resources import ResourceManagementClient
AZURE_AUTH_LOCATION = 'C:\\Users\\gsc-30310\\PycharmProjects\\Azure\\my.azureauth'
auth_file_path = getenv('AZURE_AUTH_LOCATION', None)
if auth_file_path is not None:
print("Authenticating with Azure using credentials in file at {0}"
.format(auth_file_path))
aciclient = get_client_from_auth_file(ContainerInstanceManagementClient)
resclient = get_client_from_auth_file(ResourceManagementClient)
else:
print("\nFailed to authenticate to Azure. Have you set the"
" AZURE_AUTH_LOCATION environment variable?\n")
Upvotes: 1
Views: 994