Hello Eugen Mihaescu,
Thank you for posting your question in the Microsoft Q&A forum.
Since Azure Maps doesn't natively provide quota management like some competitors, you'll need to build a client-side solution to monitor and control usage. Here's a comprehensive approach you may try:
1. Client-Side Request Tracking
- Implement counters for each API call type in your WinUI3 app
- Store daily counts in local storage (ApplicationData.LocalSettings)
- Reset counters at midnight using a background task
2. Usage Throttling Logic - This component tracks API consumption in real-time and enforces soft limits before hitting Azure's free-tier ceilings. The dictionary _usageCounters maintains daily tallies for each service (map tiles, imagery, etc.). The CanMakeRequest() method checks if a call would exceed your predefined safety buffer (e.g., 4,000 tiles instead of Azure’s 5,000 limit). It auto-resets counts at midnight to align with Azure’s daily quota cycle.
3. Request Interception Layer - This wrapper acts as a gatekeeper for all Azure Maps API calls. Before executing a request (e.g., fetching a tile), it:
- Checks quota availability via CanMakeRequest().
- Blocks requests that would breach limits, showing a user warning.
- Increments counters only after successful calls. By centralizing all API access through this layer, you ensure consistent enforcement across your app.
4. Visual Feedback System
- Add a usage meter in your UI showing remaining quota
- Implement progressive warnings (80%, 90%, 100%)
- At 100%, gray out the map and show explanation
5. Caching Optimization
- Implement tile caching (MemoryCache + local file storage)
- Set Cache-Control headers for maximum reuse
- Prioritize cached tiles when near quota limits
6. Fallback Behavior when quotas are reached:
- Switch to static map snapshots
- Disable non-essential layers
- Provide "Try again tomorrow" messaging
7. Emergency Kill Switch
- Maintain a secondary "disabled" API key
- Automatically rotate to disabled key when thresholds met
- Implement manual override for testing
Some Key Considerations:
- Client-side tracking isn't foolproof (users can clear storage)
- Combine with Azure Functions for more reliable server-side tracking
- Monitor actual usage in Azure Portal weekly to validate your client counts
- Consider implementing a "Lite Mode" that reduces tile requests
This approach gives you quota-like control while staying within Azure Maps' existing architecture. For more robust enforcement, you'd need to add a proxy service that tracks usage server-side before forwarding requests to Azure Maps.
If the above answer helped, please do not forget to "Accept Answer" as this may help other community members to refer the info if facing a similar issue. Your contribution to the Microsoft Q&A community is highly appreciated.