in SamplesV1/ADFCustomActivityRunner/CustomActivityRunner/CustomActivityBase.cs [94:119]
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;
}