Skip to main content

Notifications

Power Automate - Using Connectors
Unanswered

Fail to create document to Azure cosmos db by cosmos db connector (authorization)

(0) ShareShare
ReportReport
Posted on by 4

Hello

 

I have try to setup microsoft flow cosmos db connector to save data (create document) to Azure cosmos db.

 

During the setup, I have input the db account name and access key to microsoft flow connection copied from Azure cosmos db.

In the microsoft flow cosmos db connector, I can select database and collection name which implied that my Azure cosmos db key is correct and microsoft flow can connect to cosmos db. And I confirmed that this is a read-write key but not a read-only key.

 

However, when I run the flow, microsoft flow shows the following error.

 

Unauthorized.
Status code 401

 

"The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used."

 

What should I do to solve the authorization issue above?

Thank you very much.

  • thomaslau Profile Picture
    thomaslau 4 on at
    Re: Fail to create document to Azure cosmos db by cosmos db connector (authorization)

    Hi Michael @v-micsh-msft ,

     

    Thank you for your information.

    I have checked my connection information including Account ID which the input data is correct according to the instruction.

    And as mentioned, after the setup of connection, I can choose database and collection from the pull down selection box which implied the connection information for Microsoft flow is correct.

     

    I found one of issue from database type. At the very beginning, I have chosen Azure Cosmos DB (MongoDB) which only provide a password-liked key. However, according to many online resource, it shows that I should input the secondary key in Microsoft flow Cosmos DB connection setup. For Cosmos DB (MongoDB) type, Microsoft flow has the above issue if I input the key from Cosmos DB (MongoDB) [connection can get database/collection information but does not have authroization to create document].

     

    When I create another database by Azure Cosmos DB (SQL) and I fill in the secondary key in connection inforomation (Microsoft flow), and I try to enter a fixed text JSON in document of "create document" (Microsoft flow), I can create a document and save to Azure Cosmos DB (SQL). I believe that the existing Microsoft flow should work with Azure Cosmos DB (SQL) but not the Azure Cosmos DB (MongoDB) on document creation due to authorization issue.

    My workflow gets the infromation from jpg by Face API and store into Azure Cosmos DB. When I runs the workflow, the Cosmos DB connector to Azure Cosmos DB (SQL) shows error (An action failed. No dependent actions succeeded.). As my understanding, it means that the Face API is fail and does not have any information to Cosmos DB.

     

    However, in the history of Face API, it shows success (status: 200) with normal output (Face API JSON).


    Then, I removed the Cosmos DB connector. I added Gmail, and also MSSQL connector after Face API for testing.
    Both Gmail and MSSQL conector can get Face API information successfully.
    I believe that the Cosmos DB connector may have some issues to retrieve data from previous action.
    Would you kindly advise?

    Thanks & Regards,

     

    Thomas

  • v-micsh-msft Profile Picture
    v-micsh-msft on at
    Re: Fail to create document to Azure cosmos db by cosmos db connector (authorization)

    Hi @thomaslau,

     

    This might be caused by the authentication.

    Please click on the Azure cosmos DB action, then verify you have the proper connection choosed.

    63.PNG

    Further, verify your connection information again, the Account ID should be: Name of the account without 'documents.azure.com' part.

    For example:

    https://f987c3c2-ccxxx-2X1-b45e.documents.azure.com:443/

    The bold part is the Account ID.

     

    Regards,

    Michael

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard

Featured topics