Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Support SAS authentication #37310

Merged
merged 22 commits into from
Jul 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update geolocation code snippet
dubiety committed Jul 3, 2023
commit 321c1069967901a14c85d2557b49ba7484e38b4b
4 changes: 2 additions & 2 deletions sdk/maps/Azure.Maps.Geolocation/README.md
Original file line number Diff line number Diff line change
@@ -67,15 +67,15 @@ dotnet add package Azure.ResourceManager.Maps --prerelease

In the code, we need to import the following lines for both Azure Maps ResourceManager:

```C# Snippet:SasAuthImportNamespaces
```C# Snippet:GeolocationSasAuthImportNamespaces
using Azure.Maps.Geolocation;
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.Maps;
using Azure.ResourceManager.Maps.Models;
```

And then we can get SAS token via [List Sas](https://learn.microsoft.com/rest/api/maps-management/accounts/list-sas?tabs=HTTP) API and assign it to `MapsSearchClient`. In the follow code sample, we fetch a specific maps account resouce, and create a SAS token for 1 day expiry time when the code is executed.
And then we can get SAS token via [List Sas](https://learn.microsoft.com/rest/api/maps-management/accounts/list-sas?tabs=HTTP) API and assign it to `MapsSearchClient`. In the follow code sample, we fetch a specific maps account resource, and create a SAS token for 1 day expiry time when the code is executed.

```C# Snippet:InstantiateGeolocationClientViaSas
// Get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="Azure.ResourceManager" />
</ItemGroup>

<ItemGroup>
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
using System.Net;
using Azure.Core.TestFramework;
using NUnit.Framework;
#region Snippet:SasAuthImportNamespaces
#region Snippet:GeolocationSasAuthImportNamespaces
using Azure.Maps.Geolocation;
using Azure.Core;
using Azure.ResourceManager;