Skip to content

ChristopheLav/appinsights-annotate

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Application Insights Annotate action

Build and Checks Test

This action collect run metadata and publish a deployment annotation to Application Insights that allow to track deployments.

You need to set an annotation name, but the extension also publish automatically these properties:

  • Label with Success or Error
  • Server Url with value of ${{ github.server_url }}
  • Repository with value of ${{ github.repository }}
  • Workflow with value of ${{ github.workflow }}
  • Run Id with value of ${{ github.run_id }}
  • Run Number with value of ${{ github.run_number }}
  • Branch with value of ${{ github.ref_name }}
  • SHA with value of ${{ github.sha }}
  • By with value of ${{ github.actor }}
  • Event Name with value of ${{ github.event_name }}
  • Deployment Url with value of https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks

Example of a deployment annotation

What's new

Refer here to the changelog.

Breaking change of the V2:

  • Removed support of the Application Insights API keys deprecated by Microsoft
  • You now need to use the Azure Login action before the use of this action to handle the Azure authentication
  • The v1 of the action will stop to work by 31 August 2024 due to this depreciation

Official libs azure-actions-appservice-rest and azure-actions-webclient used by Microsoft in their own actions are now used.

Configuration

It is necessary to use the Azure Login action before to use this action.

Put your values into GitHub secrets to prevent clear value in your workflow.

- uses: azure/login@v1
  with:
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

On the Azure side, the minimum role required is Monitoring Contributor.

Usage

- uses: ChristopheLav/appinsights-annotate@v2
  with:
    # The `Application ID` of the Application Insights resource (available in the
    # Azure Portal under `API Access`).
    app-id: ''

    # Name of your deployment. You can set the version number or use the value
    # `github.event.head_commit.message` to set the last commit message.
    name: ''

    # Indicates if the deployment is in success.
    # Default: true
    is-deployment-succeed: true

    # Allows to treat error as warning to prevent worlflow failure. It is may not
    # important in some cases if the annotation can not be created.
    # Default: false
    treat-error-as-warning: false

License

The scripts and documentation in this project are released under the MIT License