Coder Social home page Coder Social logo

Comments (18)

 avatar commented on August 10, 2024 1

Thank you @stack111

from azuremapscodesamples.

 avatar commented on August 10, 2024

Please see #19 as well.

from azuremapscodesamples.

rbrundritt avatar rbrundritt commented on August 10, 2024

I have asked one of our developers to look into this question. We will report back shortly. Also note that the forums or the Azure support team is a much better place to ask these types of questions.

from azuremapscodesamples.

walsehgal avatar walsehgal commented on August 10, 2024

@sujayvsarma, the called function will configure the OAuth credentials to acquire an access token. You can visit Azure Active Directory Authentication libraries to take a look at the list of supported authentication libraries. Also the documentation on how to manage authentication in Azure Maps will help you understand on how to set up Azure AD app registration. Quick question, what language do you want to implement the function in?

from azuremapscodesamples.

 avatar commented on August 10, 2024

@walsehgal -

I have already looked at the documentation you pointed to. They were either confusing or inadequate. I had raised a bug on them which they seem intent on closing instead of addressing.

Which is why I raised this issue hoping that developers will help me with the problem.

Language would be C#.

from azuremapscodesamples.

rbrundritt avatar rbrundritt commented on August 10, 2024

from azuremapscodesamples.

 avatar commented on August 10, 2024

OMG. Then this request is a waste of time already?

from azuremapscodesamples.

rbrundritt avatar rbrundritt commented on August 10, 2024

You can also reach out to the Azure support team as well: https://azure.microsoft.com/support/options/ if you want more in-depth support.

from azuremapscodesamples.

walsehgal avatar walsehgal commented on August 10, 2024

@sujayvsarma, below is a sample async function deployed as an azure function, it acquires the access token. Hope this helps.

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");
  
    // Replace the tenant name 
    var authenticationContext = new AuthenticationContext("https://login.microsoftonline.com/<tenant_name>", false);
    
    // Config for OAuth client credentials 
    ClientCredential clientCred = new ClientCredential("<Replace with client ID>", "<Replace with client secret>");
    AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync("https://atlas.microsoft.com/ ", clientCred);
    string token = authenticationResult.AccessToken;
    return (ActionResult)new OkObjectResult(token);        
}

from azuremapscodesamples.

 avatar commented on August 10, 2024

from azuremapscodesamples.

walsehgal avatar walsehgal commented on August 10, 2024

This is the same function we are calling in our examples.

from azuremapscodesamples.

 avatar commented on August 10, 2024

I am satisfied with the answer Ricky provided per this reply. Specifically:

A critical part of the service that you create is including your secret token. We can't expose our service and make it reusable as there would not be a secure way to get your secret into it. Also, a lot of companies add a lot of custom logic to their service and often run the service in the same domain as their application.

With that, as well as your code sample, I am happy to close out this issue.

from azuremapscodesamples.

walsehgal avatar walsehgal commented on August 10, 2024

Glad to hear that.

from azuremapscodesamples.

 avatar commented on August 10, 2024

@walsehgal - One more question --

How do I correctly configure things between:

  • Azure Maps Application (from Create Resource > Azure Maps)
  • Azure App Service (that hosts the Maps stuff)
  • Azure AD

Basically, how do I correctly register these with each other and in my Azure AD so that I can get a valid token? I tried to set it up from what I thought was logical, I ended up getting a token as well (from the code sample), BUT, Atlas Service API refused to honour the token (HTTP 403). So, I've done something wrong somewhere. But the terminology is far too confusing to attempt to resolve it.

Please help.

from azuremapscodesamples.

walsehgal avatar walsehgal commented on August 10, 2024

@sujayvsarma, you are assigning the role to a different service principal than the one you have the token for. Please make sure you get the token for the same service principle and then add it to RBAC.

from azuremapscodesamples.

 avatar commented on August 10, 2024

@walsehgal - Basically here is what I went through:

First, I had only the Azure Maps Application (freshly created). Then from your sample code, I realized I need an App Secret. So I went to Azure AD and saw that (i) it was not registered there as an enterprise app and there was no way to do it.

So, I created a new App Registration (Azure AD > App Registrations > New), set the URLs to my local development URLs (localhost stuff). I gave it user_impersonate delegated permissions to Azure Maps API (from API Permissions). Then, I generated a secret for this application.

I used the Client ID and Secret from the App registration I had created to get the token using your sample code. It is for this token that I keep getting the HTTP 403 messages in the console logs. I can see that the call to the code is normal and seems to work fine -- My application is an ASP.NET Core 3 MVC application and I have implemented it as an Action in one of the Controllers instead of as a separate Azure function.

from azuremapscodesamples.

 avatar commented on August 10, 2024

PS: My interest in getting this flow working is currently academic. Azure Maps API does not return accurate or usable information for India and for the foreseeable future is not a viable solution for my needs.

from azuremapscodesamples.

stack111 avatar stack111 commented on August 10, 2024

Hi Sujay, point taken we need to improve our content and simpify the experience :). We definitely appreciate the feedback. Everything you described above appears accurate. However to grant access; what's missing in your steps is to add a role assignment for the application.

You have created role assignments for other service principals but the token being sent doesn't represent any of the service principals.

Alternativily we support groups in Azure AD directory. If it's easier to add your service principal to the group you can do that in the Azure AD directory. Finally, then adding the group as a role assignment.

WRT: India map data, if you want to be more specific we have a tool which can capture the problems and get them fixed.

from azuremapscodesamples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.