Beispiel #1
0
        public override void ExecuteCmdlet()
        {
            var existingProfile = FrontDoorManagementClient.FrontDoors.ListByResourceGroup(ResourceGroupName)
                                  .Where(p => p.Name.ToLower() == Name.ToLower());

            if (existingProfile.Count() != 0)
            {
                throw new PSArgumentException(string.Format(Resources.Error_CreateExistingFrontDoor,
                                                            Name,
                                                            ResourceGroupName));
            }
            var updateParameters = new Management.FrontDoor.Models.FrontDoorModel(
                id: null,
                name: Name,
                type: null,
                location: "global",
                tags: Tag.ToDictionaryTags(),
                friendlyName: Name,
                routingRules: RoutingRule?.Select(x => x.ToSdkRoutingRule()).ToList(),
                loadBalancingSettings: LoadBalancingSetting?.Select(x => x.ToSdkLoadBalancingSetting()).ToList(),
                healthProbeSettings: HealthProbeSetting?.Select(x => x.ToSdkHealthProbeSetting()).ToList(),
                backendPools: BackendPool?.Select(x => x.ToSdkBackendPool()).ToList(),
                frontendEndpoints: FrontendEndpoint?.Select(x => x.ToSdkFrontendEndpoints()).ToList(),
                enabledState: !this.IsParameterBound(c => c.EnabledState)? "Enabled" : EnabledState.ToString(),
                backendPoolsSettings: new Management.FrontDoor.Models.BackendPoolsSettings(
                    DisableCertificateNameCheck ? PSEnforceCertificateNameCheck.Disabled.ToString() : PSEnforceCertificateNameCheck.Enabled.ToString())
                );

            updateParameters.ToPSFrontDoor().ValidateFrontDoor(ResourceGroupName, this.DefaultContext.Subscription.Id);
            if (ShouldProcess(Resources.FrontDoorTarget, string.Format(Resources.CreateFrontDoor, Name)))
            {
                try
                {
                    var frontDoor = FrontDoorManagementClient.FrontDoors.CreateOrUpdate(
                        ResourceGroupName,
                        Name,
                        updateParameters
                        );
                    WriteObject(frontDoor.ToPSFrontDoor());
                }
                catch (Microsoft.Azure.Management.FrontDoor.Models.ErrorResponseException e)
                {
                    throw new PSArgumentException(string.Format(Resources.Error_ErrorResponseFromServer,
                                                                e.Response.Content));
                }
            }
        }