[英]Azure python sdk - getting information of Automation account
I want to get details of Automation Account in a resource group. 我想在资源组中获取自动化帐户的详细信息。 I have come across this class azure.mgmt.automation.operations.AutomationAccountOperations . 我遇到过此类azure.mgmt.automation.operations.AutomationAccountOperations。 The parameters required are client,config ,serializer and deserializer. 所需的参数是client,config,serializer和deserializer。 I am not sure what these parameters are . 我不确定这些参数是什么。 Can any one please elaborate with an example. 谁能举例说明一下。
here is the documentation that i am referring 这是我要参考的文档
https://azure.github.io/azure-sdk-for-python/ref/azure.mgmt.automation.operations.html#azure.mgmt.automation.operations.Operations https://azure.github.io/azure-sdk-for-python/ref/azure.mgmt.automation.operations.html#azure.mgmt.automation.operations.Operations
my sample code is 我的示例代码是
> from azure.common.credentials import UserPassCredentials from
> azure.mgmt.resource import ResourceManagementClient from
> azure.mgmt.compute import ComputeManagementClient from
> azure.mgmt.automation.operations.automation_account_operations import
> AutomationAccountOperations
>
>
> GROUP_NAME = 'group_name'
>
> subscription_id = '111111-11111-11111-1111'
>
>
> credentials = UserPassCredentials(
> 'user123@xyz.com',
> 'password' )
>
>
> automation_client =
> AutomationAccountOperations(credentials,subscription_id)
>
> def get_automation_details():
> for item in automation_client.list(GROUP_NAME):
> print(item)
Here is my sample code using azure-mgmt-automation
package in Python 3. It works fine for me. 这是我在Python 3中使用azure-mgmt-automation
包的示例代码。它对我来说很好。
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.automation import AutomationClient
subscription_id = '<your subscription id, like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>'
credentials = ServicePrincipalCredentials(
client_id='<your client id registered in AAD, like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>',
secret='<your client secret>',
tenant='<your tenant id, like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>'
)
client = AutomationClient(credentials, subscription_id)
# List all automation accounts in the subscription
all = client.automation_account.list()
for item in all:
print(item)
# List the automation accounts of a resource group
resource_group_name = '<your resource group name>'
accounts_by_rg = client.automation_account.list_by_resource_group(resource_group_name)
for item in accounts_by_rg:
print(item)
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.