简体   繁体   English

Azure Python SDK-获取自动化帐户的信息

[英]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.

相关问题 无法使用 Azure python SDK 提取正确信息或更新存储帐户 - Can't pull proper information with Azure python SDK or update storage account 使用 Azure Python SDK 返回有关 Azure LoadBalancer 的信息 - Return information on Azure LoadBalancer with Azure Python SDK python azure sdk - 列出存储帐户 SKU - python azure sdk - To list storage account SKU Azure python sdk - 获取机器状态 - Azure python sdk - getting the machine state 用python实现Facebook帐户下载自动化? - Facebook account download automation with python? Azure Python SDK问题-从RoleInstance中提取终结点信息 - Azure Python SDK Issue - Extracting endpoint information from RoleInstance "在 Python 脚本运行手册(Azure 自动化帐户)中使用子进程库运行 PowerShell 命令时遇到问题" - Trouble running PowerShell command with subprocess library in Python script runbook (Azure automation account) Python Facebook SDK:获取有关用户朋友的信息 - Python Facebook SDK: Getting information about a user's friends 有没有一种方法可以使用 Azure Azure Python SDK 或 API 来获取可在您的 Azure 帐户上创建的最大虚拟机数量? - Is there a way to get the maximum number of virtual machines that can be created on your Azure account using the Azure Python SDK or the API? 有没有一种方法可以在蔚蓝的python sdk api中获取虚拟机的vcpu数量? - is there a way of getting the vcpu amount of a vm in azure python sdk api?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM