Code Monkey home page Code Monkey logo

aci-vsts-pr-reviewer-logicapps-servicebus's Introduction

page_type languages products description urlFragment
sample
javascript
azure
azure-devops
azure-service-bus
azure-logic-apps
An Azure Pipelines pull request review service, built on Azure Container Instance, Azure Logic App and Azure Service Bus.
aci-azure-pipelines-pr-reviewer-logicapps-servicebus

Azure Pipelines PR Reviewer

An Azure Pipelines pull request review service, built on Azure Container Instance, Azure Logic App and Azure Service Bus.

How it works

When a Azure Pipelines pull request is created or updated, Azure Pipelines sends a notification to an Azure Service Bus topic. As a subscriber of the topic, an Azure Logic App starts an Azure Container Instance upon getting the notification. The container in Azure Container Instance utilizes Azure Pipelines REST API to check the changes in the pull request, leave comments and vote approve/wait.

How to deploy

Deploy ARM template

The ARM template deployment deploys Logic App, Service Bus Namepsace and Topic, it also registers Logic App as a subscriber of the Service Bus Topic. Logic App is configured to start a Container Instance with docker image wenwu/pr-review when getting a message from the Service Bus topic.

Authorize ACI connection in Logic App

To grant Logic App the permission to create Container Instance, we need to authorize ACI connection in Logic App.

After deployment, navigate to the resource group in Azure portal, open the logic app resource:

Open designer (click "Edit" button), click "Connections" in the flow:

Click "Invalid connection" to configure connection:

Sign in with user account or service pricipal.

Click "Save" button to save the changes.

Configure Azure Pipelines

Configure Service Hook

Service hooks enable you to perform tasks on other services when events happen in your Azure Pipelines projects. We will configure service hook so that message will be sent to Serivce Bus Topic when pull request is created.

  1. Get service bus topic connection string with commands, <resource-group-name> is the name of resource group used for ARM template deployment:
groupName=<resource-group-name>
nsName=$(az servicebus namespace list -g $groupName | jq -r ".[0].name")
az servicebus topic authorization-rule keys list -g $groupName --namespace-name $nsName --topic-name vsts-pr-update -n vsts-hook | jq -r ".primaryConnectionString" | rev | cut -d ';' -f2- | rev

Copy the connection string. You will need to provide this value when creating a Service Hook subscription.

  1. Go to Azure Pipelines project to configure service hook.

Click "Create subscription"

Select "Azure Service Bus" and click "Next".

Select "Pull Request created" trigger, configure "Repository", "Target branch" and other filters if applies, click "Next".

Select "Send a message to a Service Bus Topic" at "Perform this action", input the connection string got in step 1 at "SAS connection string", input "vsts-pr-update" at "Topic name", click "Test" to test, then click "Finsh".

Optionally, another subscription can be created to send message when a pull request is updated.

Get VSTS personal access token

The reviewer application running in Azure Container Instance uses a Azure Pipelines personal access token to read, comment and vote on a pull request.

Log in Azure Pipelines, go to your security details.

Create a personal access token

Select the "Code (read and write)" scope for the token, click "Save"

When you're done, make sure to copy the token. You'll use this token in next step.

Treat the token as secret, the token is your identity and acts as you when it is used.

Upload VSTS config

The reviewer application running in Azure Container Instance reads configuration file on an Azure Storage File Share to get the personal access token and other Azure Pipelines information.

Download the config.json as a template, change the value according to your Azure Pipelines project.

userId can be get via Accounts API ( accountId in response ) or Get Pull Request API ( createdBy.Id in response )

Use Azure Portal to upload the config.json file to Azure Storage File Share, navigate to the resource group in Azure portal, open the storage resource (resource name may vary):

Click "Files",

Click "vsts-pr-preview", then click "config",

Click "Upload", use the file upload control to upload the config.json file.

Now your pull request review service is up and running!

aci-vsts-pr-reviewer-logicapps-servicebus's People

Contributors

jluk avatar microsoftopensource avatar msftgits avatar supernova-eng avatar v-rajagt-zz avatar wenwu449 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aci-vsts-pr-reviewer-logicapps-servicebus's Issues

Is this sample really for JavaScript?

This issue is for a: (mark with an x)

  • bug report -> please search issues before submitting
  • feature request
  • documentation issue or request
  • regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I work on the Azure SDK for JavaScript and noticed that the samples from our repo for Service Bus show up alongside this one in the samples browser:

https://docs.microsoft.com/en-us/samples/browse/?products=azure-service-bus&languages=javascript

From what I can see here this project is not actually a JavaScript project? I was wondering if it was miscategorized (perhaps logic apps or something similar would be better)

Any log messages given by the failure

None

Expected/desired behavior

Wondering if the chosen language here is possibly incorrect.

OS and Version?

Probably any :)

Versions

NA

Mention any other details that might be useful

None, just a question.

[Action Needed] This repo is inactive

This GitHub repository has been identified as a candidate for archival

This repository has had no activity in more than [x amount of time]. Long periods of inactivity present security and code hygiene risks. Archiving will not prevent users from viewing or forking the code. A banner will appear on the repository alerting users that the repository is archived.

Please see https://aka.ms/sunsetting-faq to learn more about this process.

Action

✍️

❗**If this repository is still actively maintained, please simply close this issue. Closing an issue on a repository is considered activity and the repository will not be archived.🔒

If you take no action, this repository is still inactive 30 days from today it will be automatically archived..

Need more help? 🖐️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.