Last active
April 5, 2022 02:45
-
-
Save ridomin/63942b7e7e18f15dd0010d0f565e51cb to your computer and use it in GitHub Desktop.
WithAzureSasCredentials.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static MqttClientOptionsBuilder WithAzureIoTHubCredentialsSas(this MqttClientOptionsBuilder builder, string hostName, string deviceId, string sasKey, string modelId, int sasMinutes = 60) | |
{ | |
(string username, string password) = SasAuth.GenerateHubSasCredentials(hostName, deviceId, sasKey, modelId, sasMinutes); | |
builder | |
.WithTcpServer(hostName, 8883) | |
.WithTls() | |
.WithClientId($"{deviceId}") | |
.WithCredentials(username, password); | |
return builder; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment