Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to retrieve DocumentDB partitionkeys

For performance reasons I like to select documents from the DocumentDB belonging to a single partionkey - thus a list of partionkeys is essential. I have noticed that there is a REST API available, using a URL like

https://<database>.documents.azure.com:443/dbs/<databaseid>/colls/<collectionid>/pkranges (see https://docs.microsoft.com/nl-nl/rest/api/cosmos-db/get-partition-key-ranges)

Said that I tried this, getting through the hurdle of setting the appropriate authorization header which I think I have figured out. It is something like  type=master&er=1.1&sig=<read-only primary key>.

This all results in the following query (Advanced Editor)

 

let
    Source = Json.Document(Web.Contents("https://<database>.documents.azure.com:443/dbs/<databaseid>/colls/<collectionid>/pkranges",
[Headers=[authorization="type=master&ver=1.0&sig=<read-only primary key>"]]))
in
    Source

 

 

Unfortunately all I get is a returncode 400 (Bad Request) with the explaination "Web.Contents failed to get contents ... ". 

Is the above a road to succes? Or do I miss something?

1 REPLY 1
Anonymous
Not applicable

Using the RESTED Firefox extension I figured out that I missed two required headers ... x-ms-version and x-ms-date. Now I fail with the authorization token getting a 401 as response. More for research ...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.