AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware
1.0.0
dotnet add package AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware --version 1.0.0
NuGet\Install-Package AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware -Version 1.0.0
<PackageReference Include="AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware" Version="1.0.0" />
<PackageVersion Include="AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware" Version="1.0.0" />
<PackageReference Include="AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware" />
paket add AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware --version 1.0.0
#r "nuget: AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware, 1.0.0"
#:package AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware@1.0.0
#addin nuget:?package=AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware&version=1.0.0
#tool nuget:?package=AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware&version=1.0.0
<div align="center">
πΊοΈ AzureAICommunity β Azure Maps Address Suggestion Middleware (.NET)
Find points of interest anywhere in the world directly from your AI agent pipeline using Azure Maps.
Getting Started Β· Configuration Β· Usage Β· Field Profiles Β· How It Works Β· Type Reference Β· Contributing
</div>
Overview
AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware is a plug-and-play location search layer for AI agent pipelines built on Microsoft.Agents.AI and Microsoft.Extensions.AI. It exposes a SearchSuggestionAsync AI tool that geocodes a location to coordinates (via the Azure Maps Geocoding API) and then finds real points of interest nearby (via the Azure Maps Fuzzy Search API) β returning rich address data with only the fields your scenario actually needs.
β¨ Features
| Feature | |
|---|---|
| π | Real POI search β finds actual businesses and places, not just geographic names |
| ποΈ | Field profiles β Basic, Navigation, Display, Full, or Custom to control payload size |
| π€ | AI tool integration β registers as an AITool callable by the LLM automatically |
| π | Drop-in middleware β one .UseAzureMapsSearch() call wires everything into the pipeline |
| π | Any location format β city name, landmark, full address, or coordinates |
| π‘οΈ | Culture-safe URLs β coordinates always formatted with invariant decimal separator |
π¦ Installation
dotnet add package AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware
π Quick Start
using AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using OllamaSharp;
var mapsConfig = new MapsSearchConfig
{
AzureMapsKey = Environment.GetEnvironmentVariable("AZURE_MAPS_KEY")!,
MaxResults = 5,
Profile = AddressFieldProfile.Basic,
};
var tools = MapsSearchTools.Create(mapsConfig);
IChatClient baseClient = new OllamaApiClient("http://localhost:11434/", "llama3.2");
AIAgent originalAgent = new ChatClientAgent(baseClient,
instructions: """
You are a helpful location assistant powered by Azure Maps.
Always call the Azure Maps tool whenever the user asks to find any type of place.
Never answer from memory β always rely on the tool response for location data.
List every result returned by the tool without omitting any entry.
""",
tools: tools);
AIAgent agent = new AIAgentBuilder(originalAgent)
.UseAzureMapsSearch(mapsConfig)
.Build();
var response = await agent.RunAsync("Find coffee shops near Chennai and list every address.");
Console.WriteLine(response);
βοΈ Configuration
All settings are provided through a MapsSearchConfig instance:
| Property | Type | Default | Description |
|---|---|---|---|
AzureMapsKey |
string |
(required) | Azure Maps subscription key for shared-key authentication |
MaxResults |
int |
10 |
Maximum number of POI results returned per search call |
Profile |
AddressFieldProfile |
Full |
Controls which address fields are returned to the LLM |
CustomFields |
AddressFieldOptions |
None |
Exact fields to include when Profile is Custom |
var mapsConfig = new MapsSearchConfig
{
AzureMapsKey = Environment.GetEnvironmentVariable("AZURE_MAPS_KEY")!,
MaxResults = 10,
Profile = AddressFieldProfile.Navigation,
};
π§βπ» Usage
Middleware Pipeline
Register the middleware on an AIAgentBuilder so the agent automatically intercepts and handles SearchSuggestionAsync tool calls:
var tools = MapsSearchTools.Create(mapsConfig);
AIAgent agent = new AIAgentBuilder(
new ChatClientAgent(baseClient, instructions: "...", tools: tools))
.UseAzureMapsSearch(mapsConfig)
.Build();
var response = await agent.RunAsync("Find hospitals near Austin, TX.");
Console.WriteLine(response);
Custom Field Profile
Cherry-pick exactly the fields your scenario needs:
var mapsConfig = new MapsSearchConfig
{
AzureMapsKey = Environment.GetEnvironmentVariable("AZURE_MAPS_KEY")!,
MaxResults = 5,
Profile = AddressFieldProfile.Custom,
CustomFields = AddressFieldOptions.Name
| AddressFieldOptions.City
| AddressFieldOptions.Country
| AddressFieldOptions.Latitude
| AddressFieldOptions.Longitude
| AddressFieldOptions.Category,
};
ποΈ Field Profiles
Five built-in profiles control exactly which address fields reach the LLM β keeping the payload small and relevant:
| Profile | Fields included | Best for |
|---|---|---|
Basic |
Name Β· Location Β· City Β· State Β· Country Β· PostalCode | Display-only UIs, minimal payload |
Navigation |
+ Lat/Lon Β· StreetAddress Β· StreetName Β· StreetNumber Β· GeocodePoints | Turn-by-turn navigation |
Display |
+ Lat/Lon Β· BoundingBox Β· Category Β· Neighborhood | Map pins and cards |
Full |
All available fields | Maximum LLM context |
Custom |
Exactly the CustomFields flags you specify |
Any bespoke scenario |
Available AddressFieldOptions Flags
Name Β· Location Β· Latitude Β· Longitude
StreetAddress Β· StreetName Β· StreetNumber
City Β· State Β· Country Β· PostalCode Β· Neighborhood
Category Β· Confidence Β· FeatureId
MatchCodes Β· BoundingBox Β· GeocodePoints
Combine any flags with |:
CustomFields = AddressFieldOptions.Name | AddressFieldOptions.Latitude | AddressFieldOptions.Longitude
π Getting an Azure Maps Key
- Go to the Azure Portal.
- Create an Azure Maps Account resource.
- Navigate to Authentication and copy the Primary Key.
- Store the key in an environment variable:
# Windows PowerShell
$env:AZURE_MAPS_KEY = "YOUR_KEY_HERE"
# Linux / macOS
export AZURE_MAPS_KEY="YOUR_KEY_HERE"
β οΈ Never commit your Azure Maps key to source control.
π Type Reference
MapsSearchConfig
| Property | Type | Description |
|---|---|---|
AzureMapsKey |
string |
Azure Maps subscription key |
MaxResults |
int |
Max POI results per call (default 10) |
Profile |
AddressFieldProfile |
Pre-built field profile |
CustomFields |
AddressFieldOptions |
Flags used when Profile = Custom |
Address
| Property | Type | Description |
|---|---|---|
Name |
string? |
POI display name or formatted address |
Location |
string |
Freeform address string from the API |
Latitude / Longitude |
double |
Coordinates of the POI |
StreetAddress |
string? |
House number + street name |
StreetName / StreetNumber |
string? |
Individual street components |
City |
string? |
Locality / city name |
State |
string? |
State or province code |
Country |
string? |
Country name |
PostalCode |
string? |
Postal / ZIP code |
Neighborhood |
string? |
Sub-locality or borough |
Category |
string? |
POI category (e.g. coffee shop) |
Confidence |
string? |
Geocode match confidence |
BoundingBox |
double[]? |
[West, South, East, North] |
GeocodePoints |
IReadOnlyList<GeocodePoint>? |
Route and display geocode points |
MapsSearchTools
| Member | Description |
|---|---|
MapsSearchTools.Create(config) |
Creates the AITool[] array to pass to ChatClientAgent |
.UseAzureMapsSearch(config) |
Extension method β registers middleware on AIAgentBuilder |
π€ Contributing
Contributions are welcome! Please open an issue to discuss what you'd like to change before submitting a pull request.
π Repository: https://github.com/rvinothrajendran/AgentFramework
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
π€ Author
Built and maintained by Vinoth Rajendran.
- π GitHub: github.com/rvinothrajendran β follow for more projects!
- πΊ YouTube: youtube.com/@VinothRajendran β subscribe for tutorials and demos!
- πΌ LinkedIn: linkedin.com/in/rvinothrajendran β let's connect!
π License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Azure.Maps.Search (>= 2.0.0-beta.5)
- Microsoft.Agents.AI (>= 1.1.0)
- Microsoft.Extensions.AI (>= 10.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 61 | 4/21/2026 |