siddharth bansal Thanks for posting your question in Microsoft Q&A. Based on your description, you are looking to get Cosmos DB connecting string from Azure Key Vault in your Azure Function and faced an error with output binding. As per doc Attributes, ConnectionStringSetting
is the name of the app setting that bindings use to connect to Cosmos DB and empty string is not valid.
Here are the steps you can follow to achieve this:
- Enable Managed Identity for your Function app (reference: https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Chttp)
- Create an access policy in Key Vault for the managed identity (also necessary network access per doc)
- Add a new app setting (example
CosmosDBConnName
) with Reference syntax pointing to secret name/Uri (CosmosDbUrl
in your example) and setConnectionStringSetting
asCosmosDBConnName
. (if you are testing it in local, you would need to create this setting inlocal.setting.json
(sample project by one of our MVP).
More detailed step by step instructions can be found here and doc Use Key Vault references for App Service and Azure Functions. I hope this helps and let me know if any questions.
If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.