Skip to content

Instantly share code, notes, and snippets.

@hibri
Created July 5, 2022 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hibri/5f6cbc807f602327ec61c49363e79de0 to your computer and use it in GitHub Desktop.
Save hibri/5f6cbc807f602327ec61c49363e79de0 to your computer and use it in GitHub Desktop.
[Test]
public async Task Should_have_a_successfull_pipeline_run()
{
var tenantId = "xx";
var context =
new AuthenticationContext($"https://login.microsoftonline.com/{tenantId}/");
var clientId = "x";
var clientSecret = "x";
var cc = new ClientCredential(clientId,
clientSecret);
var authResult = await context.AcquireTokenAsync("https://management.azure.com/", cc);
// prepare ADF client
var cred = new TokenCredentials(authResult.AccessToken);
var subscriptionId = "x";
using (var adfClient = new DataFactoryManagementClient(cred))
{
adfClient.SubscriptionId = subscriptionId;
var factoryName = "adf-test-spike";
var resourceGroupName = "adf-testing";
string pipelineName = "superawesomepipeline";
var pipelines = await adfClient.Pipelines.ListByFactoryAsync(resourceGroupName, factoryName);
Assert.That(pipelines.Any(p => p.Name.Equals(pipelineName)), Is.True);
var myPipeline = await adfClient.Pipelines.GetAsync(resourceGroupName, factoryName, pipelineName);
myPipeline.Validate();
var runResponse = await adfClient.Pipelines.CreateRunAsync(resourceGroupName, factoryName, pipelineName);
var pipelineRun = await adfClient.PipelineRuns.GetAsync(resourceGroupName, factoryName, runResponse.RunId);
while (pipelineRun.Status.Equals("Queued") || pipelineRun.Status.Equals("InProgress"))
{
Thread.Sleep(1000);
pipelineRun = await adfClient.PipelineRuns.GetAsync(resourceGroupName, factoryName, runResponse.RunId);
}
Assert.That(pipelineRun.Status, Is.EqualTo("Succeeded"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment