The backend and APIs for Microsoft Azure VisionAI react app, developed using Node.js and Expressjs For more details, you can check the frontend app in this repository azure_ai_vision_frontend
To get started with the project, clone the repository and install the dependencies:
git clone https://github.com/Moustafaa91/azure_ai_vision_be.git
cd azure_ai_vision_be
npm installCreate a .env file in the root directory with the following variables:
# Azure Vision AI API Configuration
VISION_ENDPOINT=your_azure_vision_endpoint_here
VISION_KEY=your_azure_vision_key_here
# Security Configuration
ALLOWED_ORIGINS=comma_separated_frontend_urls| Variable | Description | Required | Example |
|---|---|---|---|
VISION_ENDPOINT |
Your Azure Vision AI API endpoint URL | ✅ Yes | https://your-resource.cognitiveservices.azure.com/ |
VISION_KEY |
Your Azure Vision AI API subscription key | ✅ Yes | your_azure_api_key_here |
ALLOWED_ORIGINS |
Comma-separated list of allowed website domains | ✅ Yes | https://azure-ai-vision.netlify.app,https://www.azure-ai-vision.netlify.app |
- Go to the Azure Portal
- Create or navigate to your Azure Cognitive Services resource
- Go to Keys and Endpoint section
- Copy the Endpoint URL and Key 1 or Key 2
- Add them to your
.envfile
To start the server:
npm startThe server will start on port 3000 by default.
Analyzes an image using Azure Vision AI API.
Request Body:
{
"url": "https://example.com/image.jpg",
"genderNeutral": "false"
}Response:
{
"captionResult": { ... },
"denseCaptionsResult": { ... },
"objectsResult": { ... },
"peopleResult": { ... },
"readResult": { ... },
"smartCropsResult": { ... },
"tagsResult": { ... }
}- Clone the repository
- Install dependencies:
npm install - Create
.envfile with your credentials - Start the server:
npm start
Make sure to set these environment variables in your production environment:
VISION_ENDPOINT: Your Azure Vision API endpointVISION_KEY: Your Azure Vision API keyALLOWED_ORIGINS: Your production website domains
- Never commit
.envfiles to version control - Use HTTPS in production
- Monitor logs for suspicious activity
- Regularly rotate API keys
Contributions are welcome! Please create an issue or submit a pull request.
This project is developed as part of a learning initiative and leverages the power of AI-driven vision analysis provided by Microsoft Azure. Thanks to GitHub Copilot and ChatGPT for assisting with coding and development :)
For any inquiries, please contact Moustafa Attia.