This directory contains automation scripts for indexing blog posts into Azure Cognitive Search, enabling enhanced search capabilities for the Azure OSS Developer Support blog.
The Azure Cognitive Search integration provides powerful search functionality by automatically indexing blog post content, metadata, and tags. The indexing process extracts structured data from Jekyll markdown files and uploads it to a configured Azure Search service.
_posts
directoryBefore using these scripts, ensure you have:
cd azcogsearch-scripts
npm install
cp .env.example .env
# Edit .env with your Azure Search service details
npm run index
Create a .env
file in this directory with the following variables:
# Azure Search Service Configuration
AZ_SEARCH_SERVICE_NAME=your-search-service-name
AZ_SEARCH_ADMIN_KEY=your-admin-key-here
AZ_SEARCH_INDEX_NAME=blog-index
# Environment Configuration
NODE_ENV=development
Variable | Required | Description | Example |
---|---|---|---|
AZ_SEARCH_SERVICE_NAME |
✅ | Name of your Azure Search service | myblog-search |
AZ_SEARCH_ADMIN_KEY |
✅ | Admin API key for write operations | 1234567890ABCDEF... |
AZ_SEARCH_INDEX_NAME |
❌ | Target index name (defaults to blog-index ) |
blog-posts-prod |
NODE_ENV |
❌ | Environment for logging verbosity | development or production |
azcogsearch-scripts/
├── README.md # This documentation
├── package.json # Node.js project configuration
├── package-lock.json # Dependency lock file
├── .env.example # Environment variable template
├── .gitignore # Git ignore rules
├── feed-index.js # Main indexing script
└── blog-data.js # Blog post processing utilities
Index all blog posts to Azure Cognitive Search:
npm run index
Run with enhanced logging for troubleshooting:
NODE_ENV=development npm run index
Run with minimal logging for CI/CD environments:
NODE_ENV=production npm run index
The script creates documents in Azure Search with the following structure:
{
"@search.action": "mergeOrUpload",
"id": "2023-01-01-example-post",
"title": "Example Blog Post Title",
"tags": ["azure", "nodejs", "tutorial"],
"categories": ["development", "cloud"],
"description": "Brief description of the post (120 characters max)",
"content": "Full post content with markdown removed",
"url": "/2023/01/01/example-post/index.html",
"pubDate": "2023-01-01T00:00:00.000Z"
}
❌ Missing required configuration: searchServiceName, adminApiKey
Solution: Ensure your .env
file exists and contains all required variables.
❌ Error during Azure Search indexing:
Message: Access denied
Code: 403
Solution: Verify your admin API key is correct and has write permissions.
❌ Error during Azure Search indexing:
Message: getaddrinfo ENOTFOUND your-service.search.windows.net
Solution: Check your search service name and network connectivity.
⚠️ No posts found to index
Solution: Ensure blog posts exist in the _posts
directory and follow naming conventions.
Enable detailed error logging by setting:
NODE_ENV=development npm run index
This will provide:
.env
files to version controlFor automated deployments, store credentials as encrypted secrets:
GitHub Actions Example:
env:
AZ_SEARCH_SERVICE_NAME: $
AZ_SEARCH_ADMIN_KEY: $
Azure DevOps Example:
variables:
- group: azure-search-secrets
@azure/search-documents
: Official Azure SDK for search operationsdotenv
: Environment variable managementgray-matter
: Front matter parsing for Jekyll postsremove-markdown
: Content cleaning and processing_posts
directory sequentiallyWhen modifying these scripts:
Command | Description |
---|---|
npm run index |
Run the main indexing script |
npm run audit |
Check for security vulnerabilities |
npm run audit-fix |
Automatically fix security issues |
Need Help? Check the troubleshooting section above or review the Azure Search service logs for detailed error information.