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;
            }

            // Resolve the file path and read the raw content
            string rawJsonContent = DataFactoryClient.ReadJsonFileContent(this.TryResolvePath(File));

            // Resolve any mismatch between -Name and the name written in JSON
            Name = ResolveResourceName(rawJsonContent, Name, "LinkedService");

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

            WriteObject(DataFactoryClient.CreatePSLinkedService(parameters));
        }
        public virtual PSLinkedService CreatePSLinkedService(CreatePSLinkedServiceParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            
            PSLinkedService linkedService = null;
            Action createLinkedService = () =>
            {
                linkedService =
                    new PSLinkedService(CreateOrUpdateLinkedService(parameters.ResourceGroupName,
                        parameters.DataFactoryName,
                        parameters.Name,
                        parameters.RawJsonContent))
                    {
                        ResourceGroupName = parameters.ResourceGroupName,
                        DataFactoryName = parameters.DataFactoryName
                    };

                if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(linkedService.ProvisioningState))
                {
                    string errorMessage = linkedService.Properties == null
                        ? string.Empty
                        : linkedService.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.
                createLinkedService();
            }
            else
            {
                bool linkedServiceExists = CheckLinkedServiceExists(parameters.ResourceGroupName,
                    parameters.DataFactoryName, parameters.Name);

                parameters.ConfirmAction(
                        !linkedServiceExists,  // prompt only if the linked service exists
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.LinkedServiceExists,
                            parameters.Name,
                            parameters.DataFactoryName),
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.LinkedServiceCreating,
                            parameters.Name,
                            parameters.DataFactoryName),
                        parameters.Name,
                        createLinkedService);
            }

            return linkedService;
        }