How to use Managed Identity to connect to Cosmos DB and IoT Hub from Azure function

Debashis Jena 76 Reputation points
2023-06-21T14:00:41.35+00:00

Hi,

We have a IoTHub trigger function, which will be triggered when data will be received in IoT hub and it will push the data to Cosmos DB.

We are using Cosmos DB output binding to push data into cosmos DB.

How we can use managed identity instead of connection string to connect to IoT Hub and cosmos DB.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,274 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,914 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Andriy Bilous 11,821 Reputation points MVP Volunteer Moderator
    2023-06-23T05:17:45.5266667+00:00

    Hello @Debashis Jena

    You can use Managed Identity to connect from Azure Function to Azure Cosmos DB

    You need to set up a robust, key rotation agnostic solution to access Azure Cosmos DB keys by using managed identities and data plane role-based access control.

    IoT Hub also offers a way to connect to its Service control plane by using Role-Based Access Control (RBAC). On top of that, you can completely disable access for shared access policies, which used to be the only way to connect to this plane.
    https://www.vanderveer.io/iot-hub-service-managed-identity/
    https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-managed-identity


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.