コード例 #1
0
        public override void ExecuteCmdlet()
        {
            string        subid = DefaultContext.Subscription.Id;
            List <string> FrontendEndpointIds = FrontendEndpointName?.Select(x => string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/frontDoors/{2}/FrontendEndpoints/{3}",
                                                                                                subid, ResourceGroupName, FrontDoorName, x)).ToList();
            string BackendPoolId = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/frontDoors/{2}/BackendPools/{3}",
                                                 subid, ResourceGroupName, FrontDoorName, BackendPoolName);
            var RoutingRule = new PSRoutingRule
            {
                Name = Name,
                CustomForwardingPath         = CustomForwardingPath,
                ForwardingProtocol           = !this.IsParameterBound(c => c.ForwardingProtocol)? PSForwardingProtocol.MatchRequest : ForwardingProtocol,
                QueryParameterStripDirective = !this.IsParameterBound(c => c.QueryParameterStripDirective)? PSQueryParameterStripDirective.StripAll : QueryParameterStripDirective,
                DynamicCompression           = !this.IsParameterBound(c => c.DynamicCompression)? PSEnabledState.Enabled : DynamicCompression,
                EnabledState        = !this.IsParameterBound(c => c.EnabledState)? PSEnabledState.Enabled : EnabledState,
                BackendPoolId       = BackendPoolId,
                FrontendEndpointIds = FrontendEndpointIds,
                AcceptedProtocols   = !this.IsParameterBound(c => c.AcceptedProtocol) ? new List <PSProtocol> {
                    PSProtocol.Http, PSProtocol.Https
                } : AcceptedProtocol?.ToList(),
                PatternsToMatch = !this.IsParameterBound(c => c.PatternToMatch) ? new List <string> {
                    "/*"
                } : PatternToMatch?.ToList(),
                EnableCaching = !this.IsParameterBound(c => c.EnableCaching) ? false : EnableCaching
            };

            WriteObject(RoutingRule);
        }
コード例 #2
0
        public override void ExecuteCmdlet()
        {
            string        subid = DefaultContext.Subscription.Id;
            List <string> FrontendEndpointIds = FrontendEndpointName?.Select(x => string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/frontDoors/{2}/FrontendEndpoints/{3}",
                                                                                                subid, ResourceGroupName, FrontDoorName, x)).ToList();
            string BackendPoolId = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/frontDoors/{2}/BackendPools/{3}",
                                                 subid, ResourceGroupName, FrontDoorName, BackendPoolName);
            string RulesEngineId = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/frontDoors/{2}/RulesEngines/{3}",
                                                 subid, ResourceGroupName, FrontDoorName, RulesEngineName);

            var RoutingRule = new PSRoutingRule
            {
                Name                = Name,
                EnabledState        = !this.IsParameterBound(c => c.EnabledState) ? PSEnabledState.Enabled : EnabledState,
                FrontendEndpointIds = FrontendEndpointIds,
                AcceptedProtocols   = !this.IsParameterBound(c => c.AcceptedProtocol) ? new List <PSProtocol> {
                    PSProtocol.Http, PSProtocol.Https
                } : AcceptedProtocol?.ToList(),
                PatternsToMatch = !this.IsParameterBound(c => c.PatternToMatch) ? new List <string> {
                    "/*"
                } : PatternToMatch?.ToList(),
                RulesEngineId = this.IsParameterBound(c => c.RulesEngineName) ? RulesEngineId : ""
            };

            if (ParameterSetName == FieldsWithForwardingParameterSet)
            {
                RoutingRule.RouteConfiguration = new PSForwardingConfiguration
                {
                    CustomForwardingPath         = CustomForwardingPath,
                    ForwardingProtocol           = !this.IsParameterBound(c => c.ForwardingProtocol) ? PSForwardingProtocol.MatchRequest.ToString() : ForwardingProtocol,
                    QueryParameterStripDirective = !this.IsParameterBound(c => c.QueryParameterStripDirective) ? PSQueryParameterStripDirective.StripAll.ToString() : QueryParameterStripDirective,
                    DynamicCompression           = !this.IsParameterBound(c => c.DynamicCompression) ? PSEnabledState.Enabled : DynamicCompression,
                    BackendPoolId = BackendPoolId,
                    EnableCaching = !this.IsParameterBound(c => c.EnableCaching) ? false : EnableCaching
                };
            }
            else if (ParameterSetName == FieldsWithRedirectParameterSet)
            {
                RoutingRule.RouteConfiguration = new PSRedirectConfiguration
                {
                    RedirectProtocol  = !this.IsParameterBound(c => c.RedirectProtocol) ? PSRedirectProtocol.MatchRequest.ToString() : RedirectProtocol,
                    RedirectType      = !this.IsParameterBound(c => c.RedirectType) ? PSRedirectType.Moved.ToString() : RedirectType,
                    CustomHost        = !this.IsParameterBound(c => c.CustomHost) ? "" : CustomHost,
                    CustomFragment    = CustomFragment,
                    CustomPath        = !this.IsParameterBound(c => c.CustomPath) ? "" : CustomPath,
                    CustomQueryString = CustomQueryString
                };
            }
            WriteObject(RoutingRule);
        }