public string GetSqlConnectionString(string datasetName) { Dataset dataset = Datasets.Single(x => x.Name == datasetName); LinkedService linkedService = LinkedServices.First(x => x.Name == dataset.Properties.LinkedServiceName); if (linkedService.Properties.Type != "AzureSqlDatabase") { throw new Exception($"The linked service is of type '{linkedService.Properties.Type}'. It should be of type 'AzureSqlDatabase'."); } AzureSqlDatabaseLinkedService sqlLinkedService = linkedService.Properties.TypeProperties as AzureSqlDatabaseLinkedService; if (sqlLinkedService == null) { throw new Exception($"Unable to find data set name '{datasetName}'."); } string connectionString = sqlLinkedService.ConnectionString; if (string.IsNullOrEmpty(connectionString)) { throw new Exception($"Connection string for '{linkedService.Name}' linked service is empty."); } return(connectionString); }
public BlobUtilities GetBlob(string datasetName) { Dataset dataset = Datasets.Single(x => x.Name == datasetName); AzureBlobDataset outputProps = (AzureBlobDataset)dataset.Properties.TypeProperties; AzureStorageLinkedService outputLinkedService = LinkedServices.First(x => x.Name == dataset.Properties.LinkedServiceName).Properties.TypeProperties as AzureStorageLinkedService; string outputConnectionString = outputLinkedService?.ConnectionString; BlobUtilities outputBlob = new BlobUtilities(Logger, outputConnectionString, outputProps.FolderPath); return(outputBlob); }
public T GetLinkedService <T>(string name) where T : class { int linkedServiceCount = LinkedServices.Count(x => x.Name == name); if (linkedServiceCount == 0) { throw new Exception($"The linked service '{name}' was not found."); } if (linkedServiceCount > 1) { throw new Exception($"More than one linked service with name '{name}' were found. Only one should exist."); } return(LinkedServices.First(x => x.Name == name).Properties.TypeProperties as T); }