public async Task RegenerateKey() { string communicationServiceName = Recording.GenerateAssetName("communication-service-"); var collection = _resourceGroup.GetCommunicationServiceResources(); var communication = await CreateDefaultCommunicationServices(communicationServiceName, _resourceGroup); var keys = await communication.GetKeysAsync(); string primaryKey = keys.Value.PrimaryKey; string secondaryKey = keys.Value.SecondaryKey; string primaryConnectionString = keys.Value.PrimaryConnectionString; string secondaryConnectionString = keys.Value.SecondaryConnectionString; var parameter = new RegenerateKeyContent() { KeyType = KeyType.Primary }; var newkeys = await communication.RegenerateKeyAsync(WaitUntil.Completed, parameter); Assert.AreEqual(primaryKey, newkeys.Value.PrimaryKey); Assert.NotNull(primaryConnectionString, keys.Value.PrimaryConnectionString); parameter = new RegenerateKeyContent() { KeyType = KeyType.Secondary }; newkeys = await communication.RegenerateKeyAsync(WaitUntil.Completed, parameter); Assert.NotNull(secondaryKey, keys.Value.SecondaryKey); Assert.NotNull(secondaryConnectionString, keys.Value.SecondaryConnectionString); }
public async Task RegenerateKeyTest() { List <ApiKey> keys = await ConfigStore.GetKeysAsync().ToEnumerableAsync(); ApiKey orignalKey = keys.FirstOrDefault(); RegenerateKeyContent regenerateKeyOptions = new RegenerateKeyContent() { Id = orignalKey.Id }; ApiKey configurationStore = await ConfigStore.RegenerateKeyAsync(regenerateKeyOptions); keys = await ConfigStore.GetKeysAsync().ToEnumerableAsync(); Assert.IsTrue(keys.Where(x => x.Name == orignalKey.Name).FirstOrDefault().Value != orignalKey.Value); }
public virtual Response <FluidRelayServerKeys> RegenerateKey(RegenerateKeyContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); using var scope = _fluidRelayServerClientDiagnostics.CreateScope("FluidRelayServerResource.RegenerateKey"); scope.Start(); try { var response = _fluidRelayServerRestClient.RegenerateKey(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <ApiKey> > RegenerateKeyAsync(RegenerateKeyContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); using var scope = _configurationStoreClientDiagnostics.CreateScope("ConfigurationStoreResource.RegenerateKey"); scope.Start(); try { var response = await _configurationStoreRestClient.RegenerateKeyAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <CommunicationServiceKeys> RegenerateKey(WaitUntil waitUntil, RegenerateKeyContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); using var scope = _communicationServiceResourceCommunicationServicesClientDiagnostics.CreateScope("CommunicationServiceResource.RegenerateKey"); scope.Start(); try { var response = _communicationServiceResourceCommunicationServicesRestClient.RegenerateKey(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); var operation = new CommunicationArmOperation <CommunicationServiceKeys>(new CommunicationServiceKeysOperationSource(), _communicationServiceResourceCommunicationServicesClientDiagnostics, Pipeline, _communicationServiceResourceCommunicationServicesRestClient.CreateRegenerateKeyRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }