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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware --version 1.0.0
                    
#r "nuget: AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AzureAICommunity.Agent.Middleware.AzureMapsAddressSuggestionMiddleware&version=1.0.0
                    
Install as a Cake Tool

<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.

NuGet Version NuGet Downloads License .NET GitHub Repo GitHub Follow YouTube Channel YouTube Subscribers LinkedIn

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

  1. Go to the Azure Portal.
  2. Create an Azure Maps Account resource.
  3. Navigate to Authentication and copy the Primary Key.
  4. 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a Pull Request

πŸ‘€ Author

Built and maintained by Vinoth Rajendran.


πŸ“„ License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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