Inheritance: Microsoft.Azure.Commands.DataFactories.DataFactoryParametersBase
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            string rawJsonContent = DataFactoryClient.ReadJsonFileContent(this.TryResolvePath(File));

            Name = ResolveResourceName(rawJsonContent, Name, "Pipeline");

            CreatePSPipelineParameters parameters = new CreatePSPipelineParameters()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName = DataFactoryName,
                Name = Name,
                RawJsonContent = rawJsonContent,
                Force = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            WriteObject(DataFactoryClient.CreatePSPipeline(parameters));
        }
Beispiel #2
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName   = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            string rawJsonContent = DataFactoryClient.ReadJsonFileContent(this.TryResolvePath(File));

            Name = ResolveResourceName(rawJsonContent, Name, "Pipeline");

            CreatePSPipelineParameters parameters = new CreatePSPipelineParameters()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName   = DataFactoryName,
                Name           = Name,
                RawJsonContent = rawJsonContent,
                Force          = Force.IsPresent,
                ConfirmAction  = ConfirmAction
            };

            WriteObject(DataFactoryClient.CreatePSPipeline(parameters));
        }
        public virtual PSPipeline CreatePSPipeline(CreatePSPipelineParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PSPipeline pipeline       = null;
            Action     createPipeline = () =>
            {
                pipeline =
                    new PSPipeline(CreateOrUpdatePipeline(parameters.ResourceGroupName,
                                                          parameters.DataFactoryName,
                                                          parameters.Name,
                                                          parameters.RawJsonContent))
                {
                    ResourceGroupName = parameters.ResourceGroupName,
                    DataFactoryName   = parameters.DataFactoryName
                };

                if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(pipeline.ProvisioningState))
                {
                    string errorMessage = pipeline.Properties == null
                        ? string.Empty
                        : pipeline.Properties.ErrorMessage;
                    throw new ProvisioningFailedException(errorMessage);
                }
            };

            if (parameters.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not.
                createPipeline();
            }
            else
            {
                bool pipelineExists = CheckPipelineExists(parameters.ResourceGroupName,
                                                          parameters.DataFactoryName, parameters.Name);

                parameters.ConfirmAction(
                    !pipelineExists,      // prompt only if the linked service exists
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.PipelineExists,
                        parameters.Name,
                        parameters.DataFactoryName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.PipelineCreating,
                        parameters.Name,
                        parameters.DataFactoryName),
                    parameters.Name,
                    createPipeline);
            }

            return(pipeline);
        }
        public virtual PSPipeline CreatePSPipeline(CreatePSPipelineParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PSPipeline pipeline = null;
            Action createPipeline = () =>
            {
                pipeline =
                    new PSPipeline(CreateOrUpdatePipeline(parameters.ResourceGroupName,
                        parameters.DataFactoryName,
                        parameters.Name,
                        parameters.RawJsonContent))
                    {
                        ResourceGroupName = parameters.ResourceGroupName,
                        DataFactoryName = parameters.DataFactoryName
                    };

                if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(pipeline.ProvisioningState))
                {
                    string errorMessage = pipeline.Properties == null
                        ? string.Empty
                        : pipeline.Properties.ErrorMessage;
                    throw new ProvisioningFailedException(errorMessage);
                }
            };

            if (parameters.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not.
                createPipeline();
            }
            else
            {
                bool pipelineExists = CheckPipelineExists(parameters.ResourceGroupName,
                    parameters.DataFactoryName, parameters.Name);

                parameters.ConfirmAction(
                        !pipelineExists,  // prompt only if the linked service exists
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.PipelineExists,
                            parameters.Name,
                            parameters.DataFactoryName),
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.PipelineCreating,
                            parameters.Name,
                            parameters.DataFactoryName),
                        parameters.Name,
                        createPipeline);
            }

            return pipeline;
        }