Microsoft.Azure.Commands.DataFactories.DataFactoryClient.ReadJsonFileContent C# (CSharp) Method

ReadJsonFileContent() public method

public ReadJsonFileContent ( string path ) : string
path string
return string
        public virtual string ReadJsonFileContent(string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException(path);
            }

            using (TextReader reader = new StreamReader(path))
            {
                return reader.ReadToEnd();
            }
        }
    }

Usage Example

        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));
        }
All Usage Examples Of Microsoft.Azure.Commands.DataFactories.DataFactoryClient::ReadJsonFileContent