Closed malavvakharia closed 11 months ago
Just like we can get the deviceId and moduleId dynamically can we get the iot hub connection string?
https://github.com/Azure/iotedge/issues/986
IOTEDGE_DEVICEID IOTEDGE_MODULEID
do you want to get the connection string in the module?
do you want to get the connection string in the module?
Hello @ggjjj ,
I want the IOT hub connection string in custom azure module. Not the module connection string.
You can build it yourself by quering the values of IOTEDGE_IOTHUBHOST
and IOTEDGE_DEVICEID
from the env var.
connection_string = f"HostName={iot_hub_hostname};DeviceId={device_id};SharedAccessKey=
Hello @ggjjj ,
So, what is the best practice of defining the SharedAccessKey in code?
And I want iot hub connection string not the device connection string.
Format looks like below: connection_string = f"HostName={iot_hub_hostname};SharedAccessKeyName=;SharedAccessKey="
You can set an env variable by setting the output of az iot hub connection-string show
and use that in your module to read from
Command Link source - https://learn.microsoft.com/en-us/cli/azure/iot/hub/connection-string?view=azure-cli-latest
Hey @malavvakharia did you try @ggjjj suggestion above?
Hey @malavvakharia closing this out since no response but feel free to re-open this if you are still experiencing issues.
Expected Behavior
Tell us what should happen
Current Behavior
Tell us what happens instead of the expected behavior
Steps to Reproduce
Provide a detailed set of steps to reproduce the bug. 1. 2. 3. 4.
Context (Environment)
Output of
iotedge check
Click here
```Device Information
Runtime Versions
iotedge version
]:docker version
]:Note: when using Windows containers on Windows, run
docker -H npipe:////./pipe/iotedge_moby_engine version
insteadLogs
aziot-edged logs
```edge-agent logs
```edge-hub logs
```Additional Information
Please provide any additional information that may be helpful in understanding the issue.