|

|  How to Integrate Microsoft Azure Cognitive Services with GitHub

How to Integrate Microsoft Azure Cognitive Services with GitHub

January 24, 2025

Learn how to seamlessly integrate Microsoft Azure Cognitive Services with GitHub in this comprehensive guide. Boost your productivity today!

How to Connect Microsoft Azure Cognitive Services to GitHub: a Simple Guide

 

Set Up Your Azure Cognitive Services

 

  • Navigate to the Azure Portal and sign in with your Azure account.
  •  

  • Click on "Create a resource" and search for "Cognitive Services". Click on it and then select "Create".
  •  

  • Fill in the required details such as Subscription, Resource Group, and the type of Cognitive Service you want to use (e.g., Text Analytics, Computer Vision, etc.).
  •  

  • Once the service is created, navigate to the resource page to find your Endpoint and Keys.

 

Create a GitHub Repository

 

  • Go to GitHub and log into your account. Click on the "+" icon at the top right corner and select "New repository".
  •  

  • Provide a name for your repository and a description (optional). Choose visibility settings (public or private) and click "Create repository".

 

Set Up Environment Variables

 

  • Create a new file in the root of your repository named .env. This will be used to store your sensitive Azure details like Endpoint and Keys.
  •  

AZURE_ENDPOINT=<Your Azure Cognitive Services Endpoint>
AZURE_KEY=<Your Azure Cognitive Services Key>

 

Initialize Your Project and Install Required Packages

 

  • Clone your GitHub repository to your local machine.
  •  

  • Initialize your project. If you're using Node.js, for example, you would run:
npm init -y

 

  • Install the Azure SDK client libraries suitable for your project. For general purposes, you might use:
npm install @azure/ai-text-analytics

 

Integrate Cognitive Services into Your Application

 

  • Create a new file, say analyze.js, to interact with Azure Cognitive Services.
  •  

  • Inside your file, set up the configuration and write the code to call the Azure services. Here is an example of how you might configure a Text Analytics client:
require('dotenv').config();
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");

const endpoint = process.env.AZURE_ENDPOINT;
const apiKey = process.env.AZURE_KEY;

const textAnalyticsClient = new TextAnalyticsClient(endpoint, new AzureKeyCredential(apiKey));

async function analyzeSentimentOfText(text) {
    const results = await textAnalyticsClient.analyzeSentiment([text]);
    console.log(JSON.stringify(results, null, 2));
}

analyzeSentimentOfText("Azure Cognitive Services are pretty cool!");

 

Push Changes to GitHub

 

  • Add your newly created files to git:
git add .

 

  • Commit your changes:
git commit -m "Set up Azure Cognitive Services integration"

 

  • Push your changes to the GitHub repository:
git push origin main

 

Secure Your Configuration

 

  • Ensure your .env file is listed in the .gitignore file to prevent sensitive information from being pushed to your GitHub repository.

 

.env

 

Verify Integration

 

  • Once pushed, you can verify if the integration is working by running your application and checking the output of the Cognitive Services operations.

 

Omi Necklace

The #1 Open Source AI necklace: Experiment with how you capture and manage conversations.

Build and test with your own Omi Dev Kit 2.

How to Use Microsoft Azure Cognitive Services with GitHub: Usecases

 

Enhancing Code Analysis with Microsoft Azure Cognitive Services and GitHub

 

  • Integrate Microsoft Azure Cognitive Services with GitHub to automatically analyze code for sentiment analysis in comments and documentation.
  •  

  • Utilize the Text Analytics API to extract sentiment, key phrases, and language detection from codebase comments hosted on GitHub.
  •  

  • Enable automatic pull requests to alert and suggest better phrasing or more neutral tone, improving collaboration dynamics.

 

Setting Up Azure Cognitive Services

 

  • Create an Azure Cognitive Services account and obtain API keys for Text Analytics.
  •  

  • Set up authentication and configure a simple script or function to interact with the Text Analytics API.

 


import requests

def analyze_comments(comment):
    endpoint = "https://<your-region>.api.cognitive.microsoft.com/text/analytics/v3.0/sentiment"
    headers = {"Ocp-Apim-Subscription-Key": "<your-subscription-key>", "Content-Type": "application/json"}
    data = {"documents": [{"id": "1", "language": "en", "text": comment}]}
    response = requests.post(endpoint, headers=headers, json=data)
    return response.json()

 

Integrating with GitHub

 

  • Set up a GitHub Action or webhook to trigger the Azure analysis script on code push events to the repository.
  •  

  • Parse comments from the codebase and feed them into the Azure Text Analytics function. Capture and review sentiment data.

 


name: Sentiment Analysis

on: [push]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run Sentiment Analysis
        run: python analyze_comments.py

 

Generating Feedback and Insights

 

  • Upon detecting negative sentiment, trigger a workflow to notify maintainers, providing recommendations for rephrasing.
  •  

  • Create a dashboard in GitHub to visualize trends and patterns in code comments sentiment over time.

 

Benefits of Integration

 

  • Improve team communication and collaboration by identifying potentially problematic language early.
  •  

  • Promote a more inclusive development environment through real-time feedback on communication style.

 

 

Automating Code Quality Assurance with Microsoft Azure Cognitive Services and GitHub

 

  • Leverage Microsoft Azure Cognitive Services to enhance static code analysis with language understanding AI, processing code descriptions and comments for enhanced comprehension.
  •  

  • Utilize the Language Understanding Intelligent Service (LUIS) to detect coding standards adherence and provide context-aware insights on code functionality comments hosted on GitHub.
  •  

  • Implement automated code review and feedback directly through GitHub pull requests, enhancing code quality and reducing human error.

 

Setting Up Azure Cognitive Services

 

  • Create an Azure account and deploy the Language Understanding Intelligence Service to harness AI-driven code analysis.
  •  

  • Configure an interaction module to authenticate and connect with the LUIS API using generated keys.

 


import requests

def analyze_code_description(description):
    url = "https://<your-region>.api.cognitive.microsoft.com/luis/v2.0/apps/<app-id>"
    headers = {"Ocp-Apim-Subscription-Key": "<your-subscription-key>"}
    params = {"q": description}
    response = requests.get(url, headers=headers, params=params)
    return response.json()

 

Integrating with GitHub

 

  • Configure a GitHub Action to trigger the LUIS analysis on specific repository events like pull or push requests.
  •  

  • Extract and direct code comments and descriptions to the LUIS API for context analysis, feeding back insights into relevant code sections.

 


name: Code Quality Analysis

on: [pull_request]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run LUIS Analysis
        run: python analyze_code_description.py

 

Providing Feedback and Insights

 

  • Automatically generate insightful feedback on non-compliance with coding standards and provide actionable recommendations on improving code comments.
  •  

  • Deploy a systematic report on GitHub, monitoring adherence trends and potential language issues across the codebase.

 

Benefits of Integration

 

  • Enhance coding standards compliance and documentation quality by integrating AI-driven insights into the development process.
  •  

  • Drive continuous code improvement with actionable, data-backed insights while fostering a learning environment among developers.

 

Omi App

Fully Open-Source AI wearable app: build and use reminders, meeting summaries, task suggestions and more. All in one simple app.

Github →

Order Friend Dev Kit

Open-source AI wearable
Build using the power of recall

Order Now

Troubleshooting Microsoft Azure Cognitive Services and GitHub Integration

How to connect Azure Cognitive Services to a GitHub repo?

 

Connect Azure Cognitive Services to GitHub

 

  • Create an Azure Cognitive Services resource from the Azure Portal. Note the endpoint and key values.
  •  

  • Clone your GitHub repository locally using:

    ```shell
    git clone
    ```

  •  

  • Create a script or application that uses the Cognitive Services API. For example, in Python, install the Azure package:

    ```shell
    pip install azure-cognitiveservices-vision-computervision
    ```

  •  

  • Configure your application with the endpoint and key:

    ```python
    from azure.cognitiveservices.vision.computervision import ComputerVisionClient
    from msrest.authentication import CognitiveServicesCredentials

    client = ComputerVisionClient("", CognitiveServicesCredentials(""))
    ```

  •  

  • Push changes to the GitHub repository:

    ```shell
    git add .
    git commit -m "Add Azure Cognitive Services integration"
    git push origin main
    ```

 

Why is my Azure Cognitive Services API key not working in GitHub Actions?

 

Possible Reasons Your Azure Cognitive Services API Key is Not Working

 

  • Incorrect Key: Ensure the API key in your GitHub Actions is correct. Verify it by copying directly from the Azure portal and pasting it without any extra spaces.
  •  

  • Key Expiration or Revoke: Your API key might have expired or been revoked. Check its status in Azure, and if necessary, generate a new key.
  •  

  • Improper Secret Handling: Ensure API keys are stored as secrets in GitHub, i.e., under GitHub Settings > Secrets > Actions. Use the keys in the workflow like this:

 

env:
  AZURE_API_KEY: ${{ secrets.AZURE_API_KEY }}
  
steps:
- name: Invoke API
  run: curl -H "Ocp-Apim-Subscription-Key: $AZURE_API_KEY" "<API_ENDPOINT>"

 

  • Network Issues: Verify GitHub Action runners can access Azure endpoints. Use self-hosted runners or check network restrictions in your Azure settings.
  •  

  • Region Mismatch: Ensure the API endpoint region matches the region of the created Azure Cognitive Service.

 

How do I automate deployment of Azure Cognitive Services updates using GitHub?

 

Automate Deployment with GitHub Actions

 

  • Set up a GitHub repository for your Azure Cognitive Services configuration and code.
  •  

  • Create a YAML file in the .github/workflows directory. This YAML file defines your GitHub Actions workflow that automates deployments.

 

 

Define GitHub Actions Workflow

 

  • Within the YAML file, specify the action triggers, such as pushes or pull requests to designated branches.
  •  

  • Define the jobs for your workflow, including installing dependencies, running tests, and deploying to Azure.

 

name: Azure Cognitive Services Deployment

on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Deploy to Azure
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}
    - run: az cognitive-services update --resource-group <YourResourceGroup> --name <YourServiceName>

 

 

Secure Your Credentials

 

  • Store Azure credentials in GitHub Secrets for secure access.
  •  

  • Use Azure CLI or SDK to handle the deployment inside the workflow scripts, ensuring updates are automated.

 

Don’t let questions slow you down—experience true productivity with the AI Necklace. With Omi, you can have the power of AI wherever you go—summarize ideas, get reminders, and prep for your next project effortlessly.

Order Now

Join the #1 open-source AI wearable community

Build faster and better with 3900+ community members on Omi Discord

Participate in hackathons to expand the Omi platform and win prizes

Participate in hackathons to expand the Omi platform and win prizes

Get cash bounties, free Omi devices and priority access by taking part in community activities

Join our Discord → 

OMI NECKLACE + OMI APP
First & only open-source AI wearable platform

a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded

OMI NECKLACE: DEV KIT
Order your Omi Dev Kit 2 now and create your use cases

Omi Dev Kit 2

Endless customization

OMI DEV KIT 2

$69.99

Make your life more fun with your AI wearable clone. It gives you thoughts, personalized feedback and becomes your second brain to discuss your thoughts and feelings. Available on iOS and Android.

Your Omi will seamlessly sync with your existing omi persona, giving you a full clone of yourself – with limitless potential for use cases:

  • Real-time conversation transcription and processing;
  • Develop your own use cases for fun and productivity;
  • Hundreds of community apps to make use of your Omi Persona and conversations.

Learn more

Omi Dev Kit 2: build at a new level

Key Specs

OMI DEV KIT

OMI DEV KIT 2

Microphone

Yes

Yes

Battery

4 days (250mAH)

2 days (250mAH)

On-board memory (works without phone)

No

Yes

Speaker

No

Yes

Programmable button

No

Yes

Estimated Delivery 

-

1 week

What people say

“Helping with MEMORY,

COMMUNICATION

with business/life partner,

capturing IDEAS, and solving for

a hearing CHALLENGE."

Nathan Sudds

“I wish I had this device

last summer

to RECORD

A CONVERSATION."

Chris Y.

“Fixed my ADHD and

helped me stay

organized."

David Nigh

OMI NECKLACE: DEV KIT
Take your brain to the next level

LATEST NEWS
Follow and be first in the know

Latest news
FOLLOW AND BE FIRST IN THE KNOW

thought to action

team@basedhardware.com

company

careers

events

invest

privacy

products

omi

omi dev kit

personas

resources

apps

bounties

affiliate

docs

github

help