Inheritance: Microsoft.Azure.Commands.DataFactories.DataFactoryParametersBase
        public virtual PSDataFactory CreatePSDataFactory(CreatePSDataFactoryParameters parameters)
        {
            PSDataFactory dataFactory       = null;
            Action        createDataFactory = () =>
            {
                Dictionary <string, string> tags = new Dictionary <string, string>();
                if (parameters.Tags != null)
                {
                    tags = parameters.Tags.ToDictionary();
                }

                dataFactory =
                    new PSDataFactory(
                        CreateOrUpdateDataFactory(parameters.ResourceGroupName, parameters.DataFactoryName,
                                                  parameters.Location, tags))
                {
                    ResourceGroupName = parameters.ResourceGroupName
                };
            };

            if (parameters.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the data factory exists or not.
                createDataFactory();
            }
            else
            {
                bool dataFactoryExists = CheckDataFactoryExists(parameters.ResourceGroupName, parameters.DataFactoryName);

                parameters.ConfirmAction(
                    !dataFactoryExists,    // prompt only if the data factory exists
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.DataFactoryExists,
                        parameters.DataFactoryName,
                        parameters.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.DataFactoryCreating,
                        parameters.DataFactoryName,
                        parameters.ResourceGroupName),
                    parameters.DataFactoryName,
                    createDataFactory);
            }

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

            return(dataFactory);
        }
        protected override void ProcessRecord()
        {
            CreatePSDataFactoryParameters parameters = new CreatePSDataFactoryParameters()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName = Name,
                Location = Location,
                Tags = Tags,
                Force = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            WriteObject(DataFactoryClient.CreatePSDataFactory(parameters));
        }
Esempio n. 3
0
        public override void ExecuteCmdlet()
        {
            CreatePSDataFactoryParameters parameters = new CreatePSDataFactoryParameters()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName   = Name,
                Location          = Location,
                Tags          = Tag,
                Force         = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            WriteObject(DataFactoryClient.CreatePSDataFactory(parameters));
        }
        protected override void ProcessRecord()
        {
            CreatePSDataFactoryParameters parameters = new CreatePSDataFactoryParameters()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName   = Name,
                Location          = Location,
                Tags          = Tags,
                Force         = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            WriteObject(DataFactoryClient.CreatePSDataFactory(parameters));
        }
        public override void ExecuteCmdlet()
        {
            CreatePSDataFactoryParameters parameters = new CreatePSDataFactoryParameters()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName = Name,
                Location = Location,
                Tags = Tags,
                Force = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            WriteObject(DataFactoryClient.CreatePSDataFactory(parameters));
        }
        public virtual PSDataFactory CreatePSDataFactory(CreatePSDataFactoryParameters parameters)
        {
            PSDataFactory dataFactory       = null;
            Action        createDataFactory = () =>
            {
                Dictionary <string, string> tags = new Dictionary <string, string>();
                if (parameters.Tags != null)
                {
                    tags = parameters.Tags.ToDictionary();
                }

                dataFactory =
                    new PSDataFactory(
                        CreateOrUpdateDataFactory(parameters.ResourceGroupName, parameters.DataFactoryName,
                                                  parameters.Location, tags))
                {
                    ResourceGroupName = parameters.ResourceGroupName
                };
            };

            parameters.ConfirmAction(
                parameters.Force,    // prompt only if the data factory exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DataFactoryExists,
                    parameters.DataFactoryName,
                    parameters.ResourceGroupName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DataFactoryCreating,
                    parameters.DataFactoryName,
                    parameters.ResourceGroupName),
                parameters.DataFactoryName,
                createDataFactory,
                () => CheckDataFactoryExists(parameters.ResourceGroupName, parameters.DataFactoryName, out dataFactory));

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

            return(dataFactory);
        }
        public virtual PSDataFactory CreatePSDataFactory(CreatePSDataFactoryParameters parameters)
        {
            PSDataFactory dataFactory = null;
            Action createDataFactory = () =>
            {
                Dictionary<string, string> tags = new Dictionary<string, string>();
                if (parameters.Tags != null)
                {
                    tags = parameters.Tags.ToDictionary();
                }

                dataFactory =
                    new PSDataFactory(
                        CreateOrUpdateDataFactory(parameters.ResourceGroupName, parameters.DataFactoryName,
                            parameters.Location, tags)) {ResourceGroupName = parameters.ResourceGroupName};
            };

            if (parameters.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the data factory exists or not.
                createDataFactory();
            }
            else
            {
                bool dataFactoryExists = CheckDataFactoryExists(parameters.ResourceGroupName, parameters.DataFactoryName);

                parameters.ConfirmAction(
                    !dataFactoryExists,    // prompt only if the data factory exists
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.DataFactoryExists,
                        parameters.DataFactoryName,
                        parameters.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.DataFactoryCreating,
                        parameters.DataFactoryName,
                        parameters.ResourceGroupName),
                    parameters.DataFactoryName,
                    createDataFactory);
            }

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

            return dataFactory;
        }
        public virtual PSDataFactory CreatePSDataFactory(CreatePSDataFactoryParameters parameters)
        {
            PSDataFactory dataFactory = null;
            Action createDataFactory = () =>
            {
                Dictionary<string, string> tags = new Dictionary<string, string>();
                if (parameters.Tags != null)
                {
                    tags = parameters.Tags.ToDictionary();
                }

                dataFactory =
                    new PSDataFactory(
                        CreateOrUpdateDataFactory(parameters.ResourceGroupName, parameters.DataFactoryName,
                            parameters.Location, tags))
                    { ResourceGroupName = parameters.ResourceGroupName };
            };

            parameters.ConfirmAction(
                parameters.Force,    // prompt only if the data factory exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DataFactoryExists,
                    parameters.DataFactoryName,
                    parameters.ResourceGroupName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DataFactoryCreating,
                    parameters.DataFactoryName,
                    parameters.ResourceGroupName),
                parameters.DataFactoryName,
                createDataFactory,
                () => CheckDataFactoryExists(parameters.ResourceGroupName, parameters.DataFactoryName, out dataFactory));

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

            return dataFactory;
        }