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:
- Providing the API-KEY directly (Web query - error)
- Providing the API-KEY with a PowerBI parameter, which stores the key (Web query - error)
- 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).

ApiKeyNameoption explicitly inWeb.Contents, like this?Web.Contents(url, [ApiKeyName = "subscription-key"])