Exemplo n.º 1
0
        public AppyPlayAzureConfigurationBuilder WithSignalRService(string serviceName, Region serviceRegion, ResourceSku sku = null)
        {
            var rgName      = _infraParameters.ResourceGroupParameters.ResourceGroupName;
            var skuResource = sku ?? new ResourceSku
            {
                Name = "Free_F1",
                Tier = "Free",
                Size = "F1",
            };

            var parameters = new AppySignalRParameters
            {
                ServiceName       = serviceName,
                ResourceGroupName = rgName,
                ResourceSku       = skuResource,
                Description       = serviceName,
                ServiceRegion     = serviceRegion
            };

            _infraParameters.SignalRParameters = parameters;

            return(this);
        }
Exemplo n.º 2
0
        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}");
        }
Exemplo n.º 3
0
        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}");
        }