0

I try to use the azure maps endpoint, but i am unable to access any of the endpoints from PowerBI with the Azure Maps "primary key" from my Azure Maps account instance.

https://eu.atlas.microsoft.com
https://atlas.microsoft.com

Basically i want to geolocate addresses (postal code + city name) -> [Longitude, Lattidude]

The sample response from the azure service is structured like that, and i want to access geometry points with the attribute "usageTypes":[ route]

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "address": {
          "countryRegion": {
            "name": "United States"
          },
          "adminDistricts": [
            {
              "shortName": "WA"
            },
            {
              "shortName": "King County"
            }
          ],
          "formattedAddress": "15127 NE 24th St, Redmond, WA 98052",
          "streetName": "NE 24th St",
          "streetNumber": "15127",
          "locality": "Redmond",
          "postalCode": "98052",
          "addressLine": "15127 NE 24th St"
        },
        "type": "Address",
        "confidence": "High",
        "matchCodes": [
          "Good"
        ],
        "geocodePoints": [
          {
            "geometry": {
              "type": "Point",
              "coordinates": [
                -122.138681,
                47.630358
              ]
            },
            "calculationMethod": "Rooftop",
            "usageTypes": [
              "Display"
            ]
          },
          {
            "geometry": {
              "type": "Point",
              "coordinates": [
                -122.1386787,
                47.6302179
              ]
            },
            "calculationMethod": "Rooftop",
            "usageTypes": [
              "Route"
            ]
          }
        ]
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -122.138681,
          47.630358
        ]
      },
      "bbox": [
        -122.14632282407,
        47.626495282429325,
        -122.13103917593001,
        47.63422071757068
      ]
    }
  ]
}

Inside PowerBI i tried several approaches to use the service:

  1. Providing the API-KEY directly (Web query - error)
  2. Providing the API-KEY with a PowerBI parameter, which stores the key (Web query - error)
  3. Providing the API-KEY by a path to a text file (i tested the code segment which loads the key from the .txt - ok)

PowerBI test-query from approach 3:

let
Query1 = let

// load API-KEY from .txt
FilePath = "C:\Users\<my local path to the .txt>\API-KEY.txt",
#"API-KEY" = Text.Trim(Text.FromBinary(File.Contents(FilePath))),

url = "https://atlas.microsoft.com/geocode?api-version=2025-01-01&query=10115 Berlin&subscription-key=" & #"API-KEY",
rawResponse = Web.Contents(url),

jsonResponse = Json.Document(rawResponse),
features = jsonResponse[features], 
geocodePoints = features{0}[properties][geocodePoints], 

filteredRoutePoints = List.Select(geocodePoints, each List.Contains(Record.Field(_, "usageTypes"), "Route")),
routePoint = if List.Count(filteredRoutePoints) > 0 then List.First(filteredRoutePoints) else null,

coordinates = if routePoint <> null then routePoint[geometry][coordinates] else {null, null},

latitude = coordinates{1},
longitude = coordinates{0}
in
    [Latitude = latitude, Longitude = longitude],
    #"Converted to Table" = Record.ToTable(Query1)
in
    #"Converted to Table"

So 3 approaches and EVERYONE of them throws this error message - i can´t access the service (i tried it for multiple endpoints).

enter image description here

6
  • Have you tried using the ApiKeyName option explicitly in Web.Contents, like this? Web.Contents(url, [ApiKeyName = "subscription-key"]) Commented May 8 at 9:11
  • Use learn.microsoft.com/en-us/azure/azure-maps/… and use Azure Maps primary key Commented May 8 at 9:16
  • i tried both approaches. Still can´t authenticate with the credentials provided. (i also used the primary key of course). Commented May 8 at 9:21
  • 1
    Are you testing this in Power BI Desktop or Service? Some API calls that work in Desktop can fail in the Service unless gateway credentials are configured properly. Commented May 8 at 11:58
  • 1
    @MihirSaxena You were completely right, the fault was, that i provided the api key value directly, but Web.Contents() expected a api key name. If you want, post your comment as an aswer and i will accept it as solution for the question, so you can get some credits :) Commented May 9 at 11:06

1 Answer 1

1

This issue typically occurs when using Web.Contents() with an API that expects the key to be passed using the ApiKeyName option rather than manually appending it to the URL.

In order to resolve the problem, you should modify your Web.Contents() call to use the ApiKeyName option like this:

Web.Contents("https://atlas.microsoft.com/search/address/json", [
    ApiKeyName = "subscription-key",
    Query = [
        query = "10115 Berlin",
        "api-version" = "1.0"
    ]
])

This way, Power BI correctly includes the subscription-key in the request headers or query string as required by Azure Maps and avoids authentication issues especially when refreshing data in the Power BI.

Why this matters:

Power BI treats APIs more securely when using ApiKeyName. Directly giving keys in the URL string can lead to refresh failures or prevent gateway configuration due to implicit credential use.

For reference: Web.Contents()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.