A complete Azure integration solution that captures API requests and responses from Azure API Management and forwards them to Treblle for monitoring and analytics.
Azure API Management → Azure Event Hub → Azure Function App → Treblle API
This integration leverages Azure's native services to provide real-time API monitoring:
- Azure API Management: Captures API requests/responses using policies
- Azure Event Hub: Provides reliable message streaming and buffering
- Azure Function App: Processes events and forwards to Treblle with error handling and retry logic
- Azure subscription with appropriate permissions
- Treblle account with API key and SDK token
- Azure CLI or PowerShell (for deployment)
- Visual Studio Code with Azure Functions extension (recommended)
- Create Event Hub Namespace
- Create Event Hub
- Configure Access Policy
- Navigate to Event Hub → Settings → Shared access policies
- Create a new policy with "Send" and "Listen" permissions
- Copy the Primary connection string for later use
- Format:
Endpoint=sb://<eventhub-name>.servicebus.windows.net/;SharedAccessKeyName=<policy-name>;SharedAccessKey=<access-key>
- Create Logger in APIM
- Note the logger name (e.g.,
treblle-logger) for use in API policies
-
Apply Policy to API
- Navigate to your API in APIM
- Go to Design tab → Inbound processing → Code view
- Add the policy content from
Policy-Content.xml - Update the logger name to match your created logger
-
Policy Locations
- API Level: Applies to specific API
- Global Level: Applies to all APIs
- Operation Level: Applies to specific operations
-
Create and Activate Revision
- Go to Revisions tab
- Create new revision with your policy changes
- Set as current revision
az functionapp create \
--resource-group <resource-group> \
--consumption-plan-location <region> \
--runtime java \
--runtime-version 17 \
--functions-version 4 \
--name <function-app-name> \
--storage-account <storage-account> \
--os-type WindowsUsing VS Code:
- Install Azure Functions extension
- Open project folder
- Press F1 → "Azure Functions: Deploy to Function App"
- Select your function app
Using Azure CLI:
func azure functionapp publish <function-app-name> --javaSet the following environment variables in your Function App:
| Setting | Description | Example |
|---|---|---|
AzureWebJobsStorage |
Storage account connection string | DefaultEndpointsProtocol=https;AccountName=... |
eventhubconnection |
Event Hub connection string from Step 1 | Endpoint=sb://namespace.servicebus.windows.net/;... |
eventhub |
Event Hub name | treblle-events |
consumergroup |
Event Hub consumer group | $Default |
TREBLLE_API_KEY |
Your Treblle project ID | your-project-id |
TREBLLE_SDK_TOKEN |
Your Treblle API key | your-api-key |
ADDITIONAL_MASK_KEYWORDS |
Additional fields to mask (comma-separated) | Ocp-Apim-Subscription-Key,Authorization |
- Message Retention: 1 day (minimum)
- Consumer Group: Use
$Defaultor create dedicated group
- Hosting Plan: Consumption (cost-effective for variable loads)
- Runtime: Java 17
- OS: Windows (recommended for Java Azure Functions)
- Timeout: 5 minutes (default)
- Verify Event Hub connection string
- Check consumer group exists
- Ensure function app has proper permissions
- Verify
TREBLLE_API_KEYandTREBLLE_SDK_TOKEN - Check function logs for HTTP error codes
- Ensure network connectivity to Treblle endpoints
- Monitor function execution time
- Consider upgrading to Premium plan for consistent performance
- Optimize batch processing settings
# Check function app status
az functionapp show --name <function-app-name> --resource-group <resource-group>
# View function logs
az webapp log tail --name <function-app-name> --resource-group <resource-group>
# Test Event Hub connectivity
az eventhubs eventhub show --resource-group <resource-group> --namespace-name <namespace> --name <eventhub>