Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to cosmosDB #20

Open
captain-yossarian opened this issue Jan 11, 2021 · 3 comments
Open

Connect to cosmosDB #20

captain-yossarian opened this issue Jan 11, 2021 · 3 comments

Comments

@captain-yossarian
Copy link

captain-yossarian commented Jan 11, 2021

Hi, it is more question than issue.
I know, I can ask it on stackowerflow, but since I'm asking about official way, only you know it.

Is there official way to connect to CosmosDB through RUst custom handler ?

Thanks

@fallsimply
Copy link

fallsimply commented May 7, 2021

There is an official way, using input/output bindings.
I'd also recommend you install the Azure Functions VSCode Extension (and VSCode if your not already using it)

Samples

listen for updates in the database
cosmosTrigger1/function.json

{
  "bindings": [
    {
      "type": "cosmosDBTrigger",
      "name": "documents",
      "direction": "in",
      "leaseCollectionName": "leases",
      "connectionStringSetting": "AzureWebJobsStorage",
      "databaseName": "database",
      "collectionName": "collections",
      "createLeaseCollectionIfNotExists": "true"
    }
  ]
}

Docs

In the docs, any tab other than C# should have the same function.json as you should use with Rust.

Sidenote: This question could have been asked on StackOverflow as all this info is publicly documented but it takes a good amount of research and a while to understand!

Good luck with your handler and if you need some more help feel free to reply but I can't help with Rust code/syntax

@captain-yossarian
Copy link
Author

This question could have been asked on StackOverflow

@fallsimply I have published the question on SO.
I'm waiting for your answer ))

@judedaryl
Copy link

judedaryl commented Jul 27, 2022

For anyone who had the same issue. The cosmos db data can be found under Data.”name” ( name is the name you set on the in binding ) in the request body.

I was building my http triggers first and thought the behavior was the same with “enableForwardingHttpRequest” set to true, but this only works for http triggers with every other trigger the function host sends the raw data to a with a post method and route equal to the folder name where the function.json is found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants