Logo
Blog
Automate Bug Ticket Creation from Azure App Insights to Jira

Automate Bug Ticket Creation from Azure App Insights to Jira

Avatar
Kishor Vaishnav
April 24, 2025

Introduction

JiraBug is a Python-based automation service designed to streamline exception management by integrating Azure Application Insights with Jira. It automatically captures application exceptions, filters duplicates, and creates structured Jira tickets—saving developers and DevOps teams valuable time.

adoption-trends

Explore the complete code on GitHub: https://github.com/prometheantechws/appinsights-jira-automation.git

Prerequisites

Before using JiraBug, ensure you have:

  • Python 3.8 or later
  • Azure Subscription with:
    • Application Insights
    • Azure Table Storage
    • Azure Container Registry
    • Azure Key Vault
  • Jira account (Cloud or Server)
  • Docker Desktop
  • Azure CLI
  • Python libraries: Flask, Waitress, requests, azure-data-tables, azure-identity

Installation & Setup

1. Clone the Repository


git clone https://github.com/prometheantechws/appinsights-jira-automation.git
cd appinsights-jira-automation

2. Install Dependencies


pip install -r requirements.txt

3. Configure Environment Variables

Create a .env file:


JIRA_URL=https://your-jira-instance.atlassian.net
[email protected]
JIRA_TOKEN=your-jira-api-token
JIRA_PROJECT=YOURPROJECT
AZURE_CONNECTION_STRING=your-azure-storage-connection-string
APPINSIGHTS_APP_ID=your-app-insights-app-id
APPINSIGHTS_API_KEY=your-app-insights-api-key
AZURE_VAULT_NAME=your-keyvault-name

4. Build and Run with Docker


docker build -t jirabug .
docker run -d -p 5000:5000 --env-file .env jirabug

Infrastructure Setup in Azure

You can deploy Azure resources manually via CLI or automatically with Bicep.

Option A: Manual Setup via Azure CLI

  1. Resource Group

az group create --name YourResourceGroup --location eastus
  1. Storage Account & Table

az storage account create  --name YourStorageAccount  --resource-group YourResourceGroup  --location eastus  --sku Standard_LRS
az storage table create --name ExceptionTracking --account-name YourStorageAccount
  1. Application Insights

az monitor app-insights component create  --app YourAppInsightsName  --location eastus  --resource-group YourResourceGroup  --application-type web
  1. Azure Container Registry

az acr create --resource-group YourResourceGroup --name YourACR --sku Basic
  1. Key Vault

az keyvault create --name YourKeyVault --resource-group YourResourceGroup --location eastus
  1. Store Secrets in Key Vault

az keyvault secret set --vault-name YourKeyVault --name "APPINSIGHTS-APP-ID" --value "<App Insights ID>"
az keyvault secret set --vault-name YourKeyVault --name "APPINSIGHTS-API-KEY" --value "<App Insights API Key>"
az keyvault secret set --vault-name YourKeyVault --name "JIRA-URL" --value "<Jira URL>"
az keyvault secret set --vault-name YourKeyVault --name "JIRA-EMAIL" --value "<Jira Email>"
az keyvault secret set --vault-name YourKeyVault --name "JIRA-TOKEN" --value "<Jira API Token>"
az keyvault secret set --vault-name YourKeyVault --name "JIRA-PROJECT" --value "<Jira Project Key>"
az keyvault secret set --vault-name YourKeyVault --name "AZURE-CONNECTION-STRING" --value "<Storage Connection String>"
  1. Managed Identity & Key Vault Access

az identity create --name jiraBugIdentity --resource-group YourResourceGroup
PRINCIPAL_ID=$(az identity show --name jiraBugIdentity --resource-group YourResourceGroup --query principalId -o tsv)
az keyvault set-policy  --name YourKeyVault  --object-id $PRINCIPAL_ID  --secret-permissions get
  1. Deploy Azure Container App

az containerapp env create  --name jiraBugEnv  --resource-group YourResourceGroup  --location eastus

az containerapp create  --name jiraBugApp  --resource-group YourResourceGroup  --environment jiraBugEnv  --image YourACR.azurecr.io/jirabug:latest  --assign-identity $PRINCIPAL_ID  --env-vars ENV_FILE=.env AZURE_VAULT_NAME=YourKeyVault

Option B: Automated Setup via Bicep


az deployment group create  --resource-group YourResourceGroup  --template-file infra.bicep  --parameters environmentName=dev
az deployment group create  --resource-group YourResourceGroup  --template-file main.bicep  --parameters environmentName=dev

How JiraBug Works

1. Fetching Exceptions


from dateutil.parser import parse
import requests

def query_app_insights():
   query = """
   exceptions
   | where timestamp >= ago(1h)
   | project timestamp, problemId, type, outerMessage, customDimensions
   | order by timestamp desc
   """
   response = requests.post(
       f"https://api.applicationinsights.io/v1/apps/{APPINSIGHTS_APP_ID}/query",
       headers={"X-Api-Key": APPINSIGHTS_API_KEY},
       json={"query": query},
   )
   return response.json()

2. Deduplication Logic


def is_exception_processed(problem_id, timestamp):
   client = get_table_client()
   row_key = parse(timestamp).strftime("%Y%m%d%H%M%S")
   entities = client.query_entities(f"RowKey eq '{row_key}'")
   return next(entities, None) is not None

3. Jira Ticket Creation


def create_jira_issue(summary, description):
   payload = {
       "fields": {
           "project": {"key": JIRA_PROJECT},
           "summary": summary,
           "description": description,
           "issuetype": {"name": "Bug"}
       }
   }
   response = requests.post(
       f"{JIRA_URL}/rest/api/2/issue",
       json=payload,
       auth=HTTPBasicAuth(JIRA_EMAIL, JIRA_TOKEN)
   )
   return response.json()

Running JiraBug


waitress-serve --port=5000 jirabug:app

Contributing

See the repository and contribute: https://github.com/prometheantechws/appinsights-jira-automation.git

Need Help with Automation or Azure-Jira Integration?

Thank you for reading our guide on "Automate Bug Ticket Creation from Azure App Insights to Jira". We hope this walkthrough gave you valuable insights into streamlining your bug tracking process using JiraBug.

If you have any questions, need support setting it up, or are looking to automate and scale your observability and DevOps practices—our team at PrometheanTech is here to help! Whether you're modernizing your cloud infrastructure, enhancing microservices observability, or just want to reduce the noise in your bug triage process, let’s talk.

🌐 Website: https://www.prometheanz.com

📧 Email: [email protected]


Copyright © 2025 PrometheanTech. All Rights Reserved.