Upload a File to Azure DevOps using Power Automate

Upload a File to Azure DevOps using Power Automate

Uploading a File to Azure DevOps using Power Automate

Introduction

In this blog post, we’ll explore how to automatically upload a file to an Azure DevOps repository when a new attachment is added to a SharePoint record. You can choose your desired trigger. We’ll use Power Automate to achieve this integration.

Prerequisites

Before you begin, make sure you have the following in place:

  • An Azure DevOps account
  • A SharePoint site
  • Access to Power Automate

Steps

  1. Create a SharePoint List and Flow
    • Set up a SharePoint list to store records.
    • Create a Power Automate flow triggered when a new item is added to the list.


  2. Get Attachments from SharePoint Record
    • Use the “Get attachments” action in Power Automate to retrieve attachments from the SharePoint record.
    • Store the attachment URLs in a variable.


  3. Get Attachment Contents
    • Loop through the attachments.
    • Use the “Get Attachment Content” action to get the attachment contents.
    • Convert the contents to base64 using the “base64()” function.
    • Store the base64-encoded content in a variable/compose.

  4. Upload File to Azure DevOps Repository
    • Use the Azure DevOps REST API to create a new file in the repository.
    • Make an HTTP POST request to the following endpoint using the “Send an HTTP request to Azure DevOps” action:
    • {project}/_apis/git/repositories/{repositoryId}/pushes?api-version=6.0
    • In the request body, include the base64-encoded content and specify the file path.
    • See Examples at: Pushes – Azure DevOps


Remember to replace placeholders like {organization}, {project}, and {repositoryId} with your actual values.

If you have any further questions or need assistance, feel free to ask!

This blog is part of Microsoft Azure Week! Find more similar blogs on our Microsoft Azure Landing page here.

About the author:

Shaheer Ahmad

As a Microsoft Certified Professional and Microsoft Learn Student Ambassador, I currently serve as a Power Platform & Dynamics 365 Consultant and Pod Lead at Cloud Surge. My dedication lies in delivering practical and user-friendly solutions, and I have a strong enthusiasm for learning and sharing knowledge. Active in the community, I find joy in helping others solve problems and have started sharing my learnings on my blog.

Reference:

Ahmad, S. (2024) Upload a File to Azure DevOps using Power Automate. Available at: Upload a File to Azure DevOps using Power Automate (shaheer365.blogspot.com) [Accessed on 24/06/2024]

Share this on...

Rate this Post:

Share:

Topics:

Azure

Tags: