public static async Task CreateSignalRServiceIfNotExists(this ISignalRManagementClient managementClient, ILogger logger, AppySignalRParameters parameters) { logger.Info($"Creating SignalR Service with name {parameters.ServiceName} in group {parameters.ResourceGroupName}"); var locationName = parameters.ServiceRegion.Name; var nameAvailabilityParams = new NameAvailabilityParameters(SignalRResourceType, parameters.ServiceName); var availability = await managementClient.SignalR.CheckNameAvailabilityAsync(locationName, nameAvailabilityParams); if (availability.NameAvailable == false) { logger.Info($"SignalR Service with name {parameters.ServiceName} already exists in group {parameters.ResourceGroupName}"); // TODO (compare parameters and update with CreateOrUpdateAsync) return; } var tags = new Dictionary <string, string> { { "description", parameters.Description }, }; var createParameters = new SignalRCreateParameters { Location = locationName, Sku = parameters.ResourceSku, Tags = tags }; await managementClient.SignalR.CreateOrUpdateAsync(parameters.ResourceGroupName, parameters.ServiceName, createParameters); logger.Info($"Created SignalR Service with name {parameters.ServiceName} in group {parameters.ResourceGroupName}"); }
public static async Task DeleteSignalRServiceResources(this ISignalRManagementClient managementClient, ILogger logger, AppySignalRParameters parameters) { logger.Info($"Deleting SignalR Service with name {parameters.ServiceName} in group {parameters.ResourceGroupName}"); var locationName = Region.EuropeNorth.Name; var nameAvailabilityParams = new NameAvailabilityParameters(SignalRResourceType, parameters.ServiceName); var availability = await managementClient.SignalR.CheckNameAvailabilityAsync(locationName, nameAvailabilityParams); if (availability.NameAvailable == true) { logger.Info($"SignalR Service with name {parameters.ServiceName} not exists in group {parameters.ResourceGroupName}"); return; } await managementClient.SignalR.DeleteAsync(parameters.ResourceGroupName, parameters.ServiceName); logger.Info($"Deleted SignalR Service with name {parameters.ServiceName} in group {parameters.ResourceGroupName}"); }