예제 #1
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ObjectParameterSet)
            {
                ResourceIdentifier identifier = new ResourceIdentifier(FrontDoorObject.Id);
                ResourceGroupName = identifier.ResourceGroupName;
                FrontDoorName     = identifier.ResourceName;
            }
            else if (ParameterSetName == ResourceIdParameterSet)
            {
                ResourceIdentifier identifier = new ResourceIdentifier(ResourceId);
                if (!ResourceIdentifierExtensions.IsFrontendEndpointResourceType(identifier))
                {
                    throw new PSArgumentException(string.Format(Resources.Error_InvalidResourceId, ResourceId));
                }
                ResourceGroupName = identifier.ResourceGroupName;
                Name          = identifier.ResourceName;
                FrontDoorName = ResourceIdentifierExtensions.GetFrontDoorName(identifier);
            }

            if (Name == null)
            {
                var FrontendEndpoints = FrontDoorManagementClient.FrontendEndpoints.ListByFrontDoor(ResourceGroupName, FrontDoorName).Select(p => p.ToPSFrontendEndpoints());
                WriteObject(FrontendEndpoints, true);
            }
            else
            {
                var FrontendEndpoint = FrontDoorManagementClient.FrontendEndpoints.Get(ResourceGroupName, FrontDoorName, Name);
                WriteObject(FrontendEndpoint.ToPSFrontendEndpoints());
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                if (ParameterSetName == ResourceIdParameterSet || ParameterSetName == ResourceIdWithVaultParameterSet)
                {
                    ResourceIdentifier identifier = new ResourceIdentifier(ResourceId);
                    if (!ResourceIdentifierExtensions.IsFrontendEndpointResourceType(identifier))
                    {
                        throw new PSArgumentException(string.Format(Resources.Error_InvalidResourceId, ResourceId));
                    }
                    ResourceGroupName    = identifier.ResourceGroupName;
                    FrontendEndpointName = identifier.ResourceName;
                    FrontDoorName        = ResourceIdentifierExtensions.GetFrontDoorName(identifier);
                }
                else if (ParameterSetName == ObjectParameterSet || ParameterSetName == ObjectWithVaultParameterSet)
                {
                    ResourceIdentifier identifier = new ResourceIdentifier(InputObject.Id);
                    ResourceGroupName    = identifier.ResourceGroupName;
                    FrontendEndpointName = identifier.ResourceName;
                    FrontDoorName        = ResourceIdentifierExtensions.GetFrontDoorName(identifier);
                }

                var customHttpsConfiguration = new Management.FrontDoor.Models.CustomHttpsConfiguration();

                if (ParameterSetName == FieldsParameterSet || ParameterSetName == ResourceIdParameterSet || ParameterSetName == ObjectParameterSet)
                {
                    customHttpsConfiguration.CertificateSource = PSCertificateSource.FrontDoor.ToString();
                    customHttpsConfiguration.CertificateType   = PSCertificateType.Dedicated.ToString();
                }
                else if (ParameterSetName == FieldsWithVaultParameterSet || ParameterSetName == ResourceIdWithVaultParameterSet || ParameterSetName == ObjectWithVaultParameterSet)
                {
                    customHttpsConfiguration.CertificateSource = PSCertificateSource.AzureKeyVault.ToString();
                    customHttpsConfiguration.Vault             = new Management.FrontDoor.Models.KeyVaultCertificateSourceParametersVault(VaultId);
                    customHttpsConfiguration.SecretName        = SecretName;
                    customHttpsConfiguration.SecretVersion     = SecretVersion;
                }

                customHttpsConfiguration.ProtocolType = PSProtocolType.ServerNameIndication.ToString();

                if (ShouldProcess(Resources.FrontDoorTarget, string.Format(Resources.EnableCustomDomainHttpsWarning, FrontendEndpointName)))
                {
                    FrontDoorManagementClient.FrontendEndpoints.BeginEnableHttps(ResourceGroupName, FrontDoorName, FrontendEndpointName, customHttpsConfiguration);

                    var frontDoorEndPoint = FrontDoorManagementClient.FrontendEndpoints.Get(ResourceGroupName, FrontDoorName, FrontendEndpointName);
                    WriteObject(frontDoorEndPoint.ToPSFrontendEndpoints());
                }
            }
            catch (Microsoft.Azure.Management.FrontDoor.Models.ErrorResponseException e)
            {
                throw new PSArgumentException(string.Format(
                                                  Resources.Error_ErrorResponseFromServer,
                                                  e.Response.Content));
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                if (ParameterSetName == ResourceIdParameterSet)
                {
                    ResourceIdentifier identifier = new ResourceIdentifier(ResourceId);
                    if (!ResourceIdentifierExtensions.IsFrontendEndpointResourceType(identifier))
                    {
                        throw new PSArgumentException(string.Format(Resources.Error_InvalidResourceId, ResourceId));
                    }
                    ResourceGroupName    = identifier.ResourceGroupName;
                    FrontendEndpointName = identifier.ResourceName;
                    FrontDoorName        = ResourceIdentifierExtensions.GetFrontDoorName(identifier);
                }
                else if (ParameterSetName == ObjectParameterSet)
                {
                    ResourceIdentifier identifier = new ResourceIdentifier(InputObject.Id);
                    ResourceGroupName    = identifier.ResourceGroupName;
                    FrontendEndpointName = identifier.ResourceName;
                    FrontDoorName        = ResourceIdentifierExtensions.GetFrontDoorName(identifier);
                }

                if (ShouldProcess(Resources.FrontDoorTarget, string.Format(Resources.DisableCustomDomainHttpsWarning, FrontendEndpointName)))
                {
                    FrontDoorManagementClient.FrontendEndpoints.BeginDisableHttps(ResourceGroupName, FrontDoorName, FrontendEndpointName);

                    var frontDoorEndPoint = FrontDoorManagementClient.FrontendEndpoints.Get(ResourceGroupName, FrontDoorName, FrontendEndpointName);
                    WriteObject(frontDoorEndPoint.ToPSFrontendEndpoints());
                }
            }
            catch (Microsoft.Azure.Management.FrontDoor.Models.ErrorResponseException e)
            {
                throw new PSArgumentException(string.Format(
                                                  Resources.Error_ErrorResponseFromServer,
                                                  e.Response.Content));
            }
        }