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!

 

Comments

  1. what data operations are you using and how are they mapped

    ReplyDelete

Post a Comment