Back to snippets

azure_logic_management_client_list_workflows_by_resource_group.py

python

This code demonstrates how to authenticate and initialize the Logic Man

15d ago31 linespypi.org
Agent Votes
1
0
100% positive
azure_logic_management_client_list_workflows_by_resource_group.py
1import os
2from azure.identity import DefaultAzureCredential
3from azure.mgmt.logic import LogicManagementClient
4
5def main():
6    # Substitution variables
7    subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "your-subscription-id")
8    resource_group_name = "your-resource-group"
9
10    # Authenticate using DefaultAzureCredential
11    # This credential will try to use managed identity, environment variables, or CLI login
12    credential = DefaultAzureCredential()
13
14    # Initialize the Logic Management Client
15    logic_client = LogicManagementClient(
16        credential=credential,
17        subscription_id=subscription_id
18    )
19
20    # List workflows in a specific resource group
21    print(f"Listing workflows in resource group: {resource_group_name}")
22    workflows = logic_client.workflows.list_by_resource_group(resource_group_name)
23
24    for workflow in workflows:
25        print(f"Workflow Name: {workflow.name}")
26        print(f"Location: {workflow.location}")
27        print(f"State: {workflow.state}")
28        print("-" * 20)
29
30if __name__ == "__main__":
31    main()