protected async override Task OnInitializedAsync() { var options = new ServiceClientOptions(); options.AccessToken = "Us8PhNscIfESqf-GsNTUk0fqirRivRRBDZ4aavvv8Ao"; options.AgencyBaseUri = "https://api.streetcred.id/agency/v1"; options.SubscriptionKey = "ebacdad1a9a140bb9af6321cdedddb5e"; AgencyServiceClient = new AgencyServiceClient( baseUri: new Uri("https://api.streetcred.id/agency/v1"), credentials: new StreetcredClientCredentials(Options.Create(options))); Ready = true; }
private async Task InitializeServiceClientAsync() { if (_serviceClient != null) { await _serviceClient.CloseAsync(); _serviceClient.Dispose(); _serviceClient = null; _logger.LogInformation("Closed and disposed the current service client instance."); } var options = new ServiceClientOptions { SdkAssignsMessageId = Shared.SdkAssignsMessageId.WhenUnset, }; _serviceClient = ServiceClient.CreateFromConnectionString(_iotHubConnectionString, _transportType, options); _logger.LogInformation("Initialized a new service client instance."); }
public async Task MessageIdDefaultSetToGuid_SendEventSetMessageIdIfNotSet() { // arrange using TestDevice testDevice = await TestDevice.GetTestDeviceAsync(Logger, DevicePrefix).ConfigureAwait(false); var options = new ServiceClientOptions { SdkAssignsMessageId = Shared.SdkAssignsMessageId.WhenUnset, }; using var sender = ServiceClient.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString, options); string messageId = Guid.NewGuid().ToString(); // act using var messageWithoutId = new Message(); using var messageWithId = new Message { MessageId = messageId, }; await sender.SendAsync(testDevice.Id, messageWithoutId).ConfigureAwait(false); await sender.SendAsync(testDevice.Id, messageWithId).ConfigureAwait(false); // assert messageWithoutId.MessageId.Should().NotBeNullOrEmpty(); messageWithId.MessageId.Should().Be(messageId); }
public ServiceClientConfigurator() { Options = new ServiceClientOptions(); }