Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Authentication Web query to Azure Maps Geocoding API Service - Shared Key Authentication failing

Hey there!   I got some struggles reaching the Azure Maps Geocoding API via PowerBI (web) query.   I tried several approaches: 1) Providing the API-KEY directly to the credentials prompt ("prima...
  • v-hashadapu's avatar
    1 year ago

    Hi Anonymous , Thank you for reaching out to the Microsoft Community Forum.

     

    You will need to ensure the API key is passed correctly. Power BI expects a key name when using Web.Contents and Azure Maps uses subscription-key as that key. The recommended solution is to store your Azure Maps key in a Power BI parameter for security and then reference it in a query that uses Web.Contents with ApiKeyName = "subscription-key". This setup avoids triggering the credentials prompt and aligns with both Power BI’s and Azure Maps’ authentication models.

     

    Before running the query, make sure to clear any saved permissions for https://atlas.microsoft.com in Data Source Settings and set its privacy level to Public. This step helps Power BI process the request without authentication conflicts. Once that’s done, you can use the following Power Query to send an address to Azure Maps and get geocoded results in return:

     

    let

        apiKey = AzureMapsKey, // Reference to your Power BI parameter

        locationQuery = "400 Broad St, Seattle, WA 98109", // Replace with your address

        url = "https://atlas.microsoft.com/search/address/json",

        queryParams = [

            #"api-version" = "1.0",

            query = locationQuery,

            #"subscription-key" = apiKey

        ],

        response = Web.Contents(url, [Query = queryParams, ApiKeyName = "subscription-key"]),

        json = Json.Document(response),

        results = json[results]

    in

        results

     

    If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
    Thank you.