public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            RunCmdlet(() =>
            {
                switch (ParameterSetName)
                {
                case ResourceGroupParameterSet:
                    ResolveResourceGroupName();
                    break;

                case ResourceIdParameterSet:
                    this.LoadFromResourceId();
                    break;

                case InputObjectParameterSet:
                    this.LoadFromInputObject();
                    break;

                default:
                    throw new ArgumentException(Resources.ParameterSetError);
                }

                if (ShouldProcess($"SignalR service {ResourceGroupName}/{Name}", "update"))
                {
                    PromptParameter(nameof(ResourceGroupName), ResourceGroupName);
                    PromptParameter(nameof(Name), Name);
                    PromptParameter(nameof(Sku), Sku, true, DefaultSku);
                    PromptParameter(nameof(UnitCount), UnitCount, true, DefaultUnitCount);
                    PromptParameter(nameof(Tag), Tag == null ? null : JsonConvert.SerializeObject(Tag));
                    PromptParameter(nameof(ServiceMode), ServiceMode);

                    IList <string> origins = ParseAndCheckAllowedOrigins(AllowedOrigin);
                    PromptParameter(nameof(AllowedOrigin), origins == null ? null : JsonConvert.SerializeObject(origins));


                    Sku       = Sku ?? DefaultSku;
                    UnitCount = UnitCount ?? DefaultUnitCount;

                    IList <SignalRFeature> features = ServiceMode == null ? null : new List <SignalRFeature> {
                        new SignalRFeature(flag: FeatureFlags.ServiceMode, value: ServiceMode)
                    };
                    SignalRCorsSettings cors = AllowedOrigin == null ? null : new SignalRCorsSettings(allowedOrigins: origins);

                    var parameters = new SignalRResource(
                        tags: Tag,
                        sku: new ResourceSku(name: Sku, capacity: UnitCount),
                        features: features,
                        cors: cors);

                    Client.SignalR.Update(ResourceGroupName, Name, parameters);

                    var signalr = (Client.SignalR.Get(ResourceGroupName, Name));
                    WriteObject(new PSSignalRResource(signalr));
                }
            });
        }
示例#2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            RunCmdlet(() =>
            {
                ResolveResourceGroupName(required: false);
                ResourceGroupName = ResourceGroupName ?? Name;

                if (ShouldProcess($"SignalR service {ResourceGroupName}/{Name}", "new"))
                {
                    PromptParameter(nameof(ResourceGroupName), ResourceGroupName);
                    PromptParameter(nameof(Name), Name);

                    if (Location == null)
                    {
                        Location = GetLocationFromResourceGroup();
                        PromptParameter(nameof(Location), null, true, Location, "(from resource group location)");
                    }
                    else
                    {
                        PromptParameter(nameof(Location), Location);
                    }

                    PromptParameter(nameof(Sku), Sku, true, DefaultSku);
                    PromptParameter(nameof(UnitCount), UnitCount);
                    PromptParameter(nameof(Tag), Tag == null ? null : JsonConvert.SerializeObject(Tag));
                    PromptParameter(nameof(ServiceMode), ServiceMode);

                    IList <string> origins = ParseAndCheckAllowedOrigins(AllowedOrigin);
                    PromptParameter(nameof(AllowedOrigin), origins == null ? null : JsonConvert.SerializeObject(origins));

                    Sku = Sku ?? DefaultSku;

                    IList <SignalRFeature> features = ServiceMode == null ? null : new List <SignalRFeature> {
                        new SignalRFeature(flag: FeatureFlags.ServiceMode, value: ServiceMode)
                    };
                    SignalRCorsSettings cors = AllowedOrigin == null ? null : new SignalRCorsSettings(allowedOrigins: origins);

                    var parameters = new SignalRResource(
                        location: Location,
                        tags: Tag,
                        sku: new ResourceSku(name: Sku, capacity: UnitCount),
                        features: features,
                        cors: cors);

                    Client.SignalR.CreateOrUpdate(parameters, ResourceGroupName, Name);

                    var signalr = Client.SignalR.Get(ResourceGroupName, Name);
                    WriteObject(new PSSignalRResource(signalr));
                }
            });
        }
 public PSSignalRCorsSettings(SignalRCorsSettings signalrCorsSettings)
 {
     AllowedOrigins = signalrCorsSettings.AllowedOrigins;
 }