You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-maps/how-to-dev-guide-csharp-sdk.md
+36-39Lines changed: 36 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
title: How to create Azure Maps applications using the C# REST SDK
3
3
titleSuffix: Azure Maps
4
4
description: How to develop applications that incorporate Azure Maps using the C# SDK Developers Guide.
5
-
author: eriklindeman
6
-
ms.author: eriklind
5
+
author: sinnypan
6
+
ms.author: sipa
7
7
ms.date: 11/11/2021
8
8
ms.topic: how-to
9
9
ms.service: azure-maps
@@ -12,16 +12,16 @@ services: azure-maps
12
12
13
13
# C# REST SDK Developers Guide
14
14
15
-
The Azure Maps C# SDK supports functionality available in the [Azure Maps Rest API][Rest API], like searching for an address, routing between different coordinates, and getting the geo-location of a specific IP address. This article introduces the C# REST SDK with examples to help you get started building location-aware applications in C# that incorporate the power of Azure Maps.
15
+
The Azure Maps C# SDK supports functionality available in the Azure Maps [Rest API], like searching for an address, routing between different coordinates, and getting the geo-location of a specific IP address. This article introduces the C# REST SDK with examples to help you get started building location-aware applications in C# that incorporates the power of Azure Maps.
16
16
17
17
> [!NOTE]
18
-
> Azure Maps C# SDK supports any .NET version that is compatible with [.NET standard2.0][.NET standard]. For an interactive table, see [.NET Standard versions][.NET Standard versions].
18
+
> Azure Maps C# SDK supports any .NET version that is compatible with [.NET standard] version 2.0 or higher. For an interactive table, see [.NET Standard versions].
19
19
20
20
## Prerequisites
21
21
22
-
-[Azure Maps account][Azure Maps account].
23
-
-[Subscription key][Subscription key]or other form of [authentication][authentication].
24
-
-[.NET standard][.NET standard] version 2.0 or higher.
22
+
-[Azure Maps account].
23
+
-[Subscription key]or other form of [Authentication with Azure Maps].
24
+
-[.NET standard] version 2.0 or higher.
25
25
26
26
> [!TIP]
27
27
> You can create an Azure Maps account programmatically, Here's an example using the Azure CLI:
The client object used to access the Azure Maps Search APIs require either an `AzureKeyCredential` object to authenticate when using an Azure Maps subscription key or a `TokenCredential` object with the Azure Maps client ID when authenticating using Azure Active Directory (Azure AD). For more information on authentication, see [Authentication with Azure Maps][authentication].
64
+
The client object used to access the Azure Maps Search APIs require either an `AzureKeyCredential` object to authenticate when using an Azure Maps subscription key or a `TokenCredential` object with the Azure Maps client ID when authenticating using Azure Active Directory (Azure AD). For more information on authentication, see [Authentication with Azure Maps].
65
65
66
66
### Using an Azure AD credential
67
67
68
-
You can authenticate with Azure AD using the [Azure Identity library][Identity library .NET]. To use the [DefaultAzureCredential][defaultazurecredential.NET] provider, you'll need to install the Azure Identity client library for .NET:
68
+
You can authenticate with Azure AD using the [Azure Identity library][Identity library .NET]. To use the [DefaultAzureCredential][defaultazurecredential.NET] provider, you need to install the Azure Identity client library for .NET:
69
69
70
70
```powershell
71
71
dotnet add package Azure.Identity
72
72
```
73
73
74
-
You'll need to register the new Azure AD application and grant access to Azure Maps by assigning the required role to your service principal. For more information, see [Host a daemon on non-Azure resources][Host daemon]. During this process you'll get an Application (client) ID, a Directory (tenant) ID, and a client secret. Copy these values and store them in a secure place. You'll need them in the following steps.
74
+
You need to register the new Azure AD application and grant access to Azure Maps by assigning the required role to your service principal. For more information, see [Host a daemon on non-Azure resources]. The Application (client) ID, a Directory (tenant) ID, and a client secret are returned. Copy these values and store them in a secure place. You need them in the following steps.
75
75
76
76
Set the values of the Application (client) ID, Directory (tenant) ID, and client secret of your Azure AD application, and the map resource’s client ID as environment variables:
77
77
@@ -105,7 +105,7 @@ var client = new MapsSearchClient(credential, clientId);
105
105
```
106
106
107
107
> [!IMPORTANT]
108
-
> The other environment variables created above, while not used in the code sample here, are required by `DefaultAzureCredential()`. If you do not set these environment variables correctly, using the same naming conventions, you will get run-time errors. For example, if your `AZURE_CLIENT_ID` is missing or invalid you will get an `InvalidAuthenticationTokenTenant` error.
108
+
> The other environment variables created in the previous code snippet, while not used in the code sample, are required by `DefaultAzureCredential()`. If you do not set these environment variables correctly, using the same naming conventions, you will get run-time errors. For example, if your `AZURE_CLIENT_ID` is missing or invalid you will get an `InvalidAuthenticationTokenTenant` error.
109
109
110
110
### Using a subscription key credential
111
111
@@ -167,7 +167,7 @@ foreach (var result in searchResult.Results)
167
167
}
168
168
```
169
169
170
-
The above code snippet demonstrates how to create a `MapsSearchClient` object using your Azure credentials, then uses its [FuzzySearch][FuzzySearch] method, passing in the point of interest (POI) name "_Starbucks_" and coordinates _GeoPosition(-122.31, 47.61)_. This all gets wrapped up by the SDK and sent to the Azure Maps REST endpoints. When the search results are returned, they're written out to the screen using `Console.WriteLine`.
170
+
The above code snippet demonstrates how to create a `MapsSearchClient` object using your Azure credentials, then uses its [FuzzySearch] method, passing in the point of interest (POI) name "_Starbucks_" and coordinates _GeoPosition(-122.31, 47.61)_. The SDK packages and sends the results to the Azure Maps REST endpoints. When the search results are returned, they're written out to the screen using `Console.WriteLine`.
171
171
172
172
The following libraries are used:
173
173
@@ -236,11 +236,11 @@ if (searchResult.Results.Count > 0)
236
236
}
237
237
```
238
238
239
-
Results returned by the `SearchAddress` method are ordered by confidence score and because`searchResult.Results.First()` is used, only the coordinates of the first result will be returned.
239
+
The `SearchAddress` method returns results ordered by confidence score and since`searchResult.Results.First()` is used, only the coordinates of the first result are returned.
240
240
241
241
## Batch reverse search
242
242
243
-
Azure Maps Search also provides some batch query methods. These methods will return Long Running Operations (LRO) objects. The requests might not return all the results immediately, so users can choose to wait until completion or query the result periodically. The example below demonstrates how to call the batched reverse search methods:
243
+
Azure Maps Search also provides some batch query methods. These methods return Long Running Operations (LRO) objects. The requests might not return all the results immediately, so users can choose to wait until completion or query the result periodically. The following example demonstrates how to call the batched reverse search methods:
244
244
245
245
```csharp
246
246
varqueries=newList<ReverseSearchAddressQuery>()
@@ -257,7 +257,7 @@ var queries = new List<ReverseSearchAddressQuery>()
257
257
};
258
258
```
259
259
260
-
In the above example, two queries are passed to the batched reverse search request. To get the LRO results, you have few options. The first option is to pass `WaitUntil.Completed` to the method. The request will wait until all requests are finished and return the results:
260
+
In the above example, two queries are passed to the batched reverse search request. To get the LRO results, you have few options. The first option is to pass `WaitUntil.Completed` to the method. The request waits until all requests are finished and return the results:
0 commit comments