Automating with Power Automate: Azure DevOps Task Creation

Kadir Islow | Nov 19, 2024 min read

Azure DevOps Task Creation

Let’s be real, not every automation task needs a Python script. Sometimes, you just need something that works without diving into complex coding.

The Problem

Most developers default to Python for workflow automation. But what if you’re:

Low Code, No Code Warrior

  • Stuck in a Microsoft ecosystem
  • Working with team members who can’t code
  • Need a quick solution without weeks of development

Power Automate becomes your unexpected ally.

My Setup: GitHub Release Tracking

I built a workflow that:

  • Monitors specific GitHub repository emails
  • Automatically creates Azure DevOps tasks
  • Notifies the team via Teams

How It Actually Works

  1. Email arrives from GitHub
  2. Trigger creates a work item
  3. Teams gets a notification
  4. Everyone stays in the loop

Subscribe to GitHub Repo

Email Config

After subscribing to the Terraform Azure Provider on GitHub to stay current with the latest releases, I set up email filtering:

  1. Pick the right folder in my inbox
  2. Create a subject line filter for new emails
  3. Adjust configuration based on my specific workflow needs

Work item config

When those specific emails land in my inbox, I automatically create a work item in Azure DevOps. For the title, I’m using the email subject line directly. The description gets a bit more custom treatment.

Pro Tip: Some fields are mandatory, pay special attention to the Area Path. Get this wrong, and your workflow falls apart.

Description Expressoin Explained

split(triggerBody()?['subject'], ' ')[sub(length(split(triggerBody()?['subject'], ' ')), 1)]

# explanation

1. triggerBody()?['subject']: # Gets the subject field from the trigger body.
2. split(..., ' '): # Splits the subject into an array of words.
3. length(...): # Counts the number of words.
4. sub(..., 1): # Finds the index of the last word.
5. split(...)[...]: # Retrieves the last word.

Verify created task

Here is the task in my Azure DevOps backlog…

Teams Notification Magic

Here’s the best part : I don’t want everyone manually subscribing to GitHub releases. So I built a Teams notification that:

  • Alerts the whole team automatically
  • Lets team members interact directly from the notification
  • Allows quick actions like adding tags or reassigning work

The goal? Keep everyone informed without drowning them in email notifications.

Verify teams notification

The Real Value

This isn’t about replacing code. It’s about enabling non-technical team members to create powerful automations without becoming software engineers.

For teams drowning in manual processes, low-code tools aren’t just convenient, they’re a lifeline.

Power Automate Code View

When mail arrives

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['shared_office365']['connectionId']"
            }
        },
        "fetch": {
            "queries": {
                "folderPath": "Inbox",
                "importance": "Any",
                "fetchOnlyWithAttachment": false,
                "includeAttachments": false,
                "subjectFilter": "[hashicorp/terraform-provider-azurerm] Release"
            },
            "pathTemplate": {
                "template": "/v3/Mail/OnNewEmail"
            },
            "method": "get"
        },
        "subscribe": {
            "queries": {
                "folderPath": "Inbox",
                "importance": "Any",
                "fetchOnlyWithAttachment": false
            },
            "body": {
                "NotificationUrl": "@{listCallbackUrl()}"
            },
            "pathTemplate": {
                "template": "/GraphMailSubscriptionPoke/$subscriptions"
            },
            "method": "post"
        },
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "OnNewEmailV3"
        },
        "operationMetadataId": "f88567b5-f67c-4a51-8f3d-762f2e0bbaa0"
    },
    "splitOn": "@triggerBody()?['value']"
}

Create work item

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['shared_visualstudioteamservices']['connectionId']"
            }
        },
        "method": "patch",
        "body": {
            "title": "@triggerBody()?['Subject']",
            "description": "<p>https://github.com/hashicorp/terraform-provider-azurerm/releases/tag/@{split(triggerBody()?['subject'], ' ')[sub(length(split(triggerBody()?['subject'], ' ')), 1)]}https://github.com/hashicorp/terraform-provider-azurerm/releases/tag/</p>",
            "area": "PROJECT",
            "dynamicFields": {
                "System.Tags": "automation; user-request"
            }
        },
        "path": "/@{encodeURIComponent('PROJECT')}/_apis/wit/workitems/$@{encodeURIComponent('Task')}",
        "queries": {
            "account": "ADIBCCOE"
        },
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "CreateWorkItem"
        },
        "operationMetadataId": "2f04eed2-6501-4306-be56-9a659a39ba55"
    }
}

Post adaptive card to channel

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['shared_teams']['connectionId']"
            }
        },
        "method": "post",
        "body": {
            "recipient": {
                "groupId": "719f61b9-d221-4221-9776-a9eabe87e526",
                "channelId": "19:ccfefedf1fc44c7a848bb3699382b8e9@thread.tacv2"
            },
            "messageBody": "@{body('Create_a_new_work_item')?['url']}@{body('Create_a_new_work_item')?['url']}@{body('Create_a_new_work_item')?['url']}@{body('Create_a_new_work_item')?['url']}{\n    \"type\": \"AdaptiveCard\",\n    \"body\": [\n        {\n            \"type\": \"TextBlock\",\n            \"size\": \"Medium\",\n            \"weight\": \"Bolder\",\n            \"text\": \"@{body('Create_a_new_work_item')?['fields']?['System_Title']}\"\n        },\n        {\n            \"type\": \"ColumnSet\",\n            \"columns\": [\n                {\n                    \"type\": \"Column\",\n                    \"items\": [\n                        {\n                            \"type\": \"Image\",\n                            \"style\": \"Person\",\n                            \"url\": \"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTK9TWru7CyaKoTW60nsuMSMJqVNQHjJYCvzA&usqp=CAU\",\n                            \"altText\": \"@{body('Create_a_new_work_item')?['fields']?['System_CreatedBy']}\",\n                            \"size\": \"Small\"\n                        }\n                    ],\n                    \"width\": \"auto\"\n                },\n                {\n                    \"type\": \"Column\",\n                    \"items\": [\n                        {\n                            \"type\": \"TextBlock\",\n                            \"weight\": \"Bolder\",\n                            \"text\": \"@{body('Create_a_new_work_item')?['fields']?['System_CreatedBy']}\",\n                            \"wrap\": true\n                        },\n                        {\n                            \"type\": \"TextBlock\",\n                            \"spacing\": \"None\",\n                            \"text\": \"@{triggerBody()?['bodyPreview']}\",\n                            \"isSubtle\": true,\n                            \"wrap\": true\n                        }\n                    ],\n                    \"width\": \"stretch\"\n                }\n            ]\n        },\n        {\n            \"type\": \"TextBlock\",\n            \"text\": \"\",\n            \"wrap\": true\n        }\n    ],\n    \"actions\": [\n        {\n            \"type\": \"Action.OpenUrl\",\n            \"title\": \"View\",\n            \"url\": \"https://dev.azure.com/ADIBCCOE/ADIB-automation-Dev-project/_boards/board/t/ADIB-automation-Dev-project%20Team/Backlog%20items?workitem=@{body('Create_a_new_work_item')?['fields']?['System_Id']}\"\n        }\n    ],\n    \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n    \"version\": \"1.5\"\n}\n"
        },
        "path": "/v1.0/teams/conversation/adaptivecard/poster/@{encodeURIComponent('User')}/location/@{encodeURIComponent('Channel')}",
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "operationMetadataId": "d0869e5e-3f0e-4312-99ee-f49bde5702d4",
        "flowSystemMetadata": {
            "swaggerOperationId": "PostCardToConversation"
        }
    }
}