Skip to content

Commit ad79ced

Browse files
committed
Check if the client is connected for AzureDataFactory service implementation
1 parent 185aa9c commit ad79ced

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

ProcessMyMedia/Services/AzureDataFactoryServiceV2.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace ProcessMyMedia.Services
22
{
33
using System;
4+
using System.Security;
45
using System.Linq;
56
using System.Threading.Tasks;
67
using System.Collections.Generic;
@@ -63,6 +64,11 @@ public async Task AuthAsync()
6364
/// <returns></returns>
6465
public async Task<Model.LinkedServiceEntity> GetLinkedServiceAsync(string name)
6566
{
67+
if (this.client == null)
68+
{
69+
throw new SecurityException("Not Authenticated");
70+
}
71+
6672
var linkedService = await this.client.LinkedServices.GetAsync(
6773
this.configuration.ResourceGroup,
6874
this.configuration.FactoryName,
@@ -81,6 +87,11 @@ public async Task AuthAsync()
8187
/// <returns></returns>
8288
public async Task<Model.LinkedServiceEntity> CreateOrUpdateLinkedServiceAsync(string name, string type, object typeProperties)
8389
{
90+
if (this.client == null)
91+
{
92+
throw new SecurityException("Not Authenticated");
93+
}
94+
8495
var linkedService = await this.client.LinkedServices.CreateOrUpdateAsync(
8596
this.configuration.ResourceGroup,
8697
this.configuration.FactoryName,
@@ -102,6 +113,11 @@ public async Task AuthAsync()
102113
/// <returns></returns>
103114
public async Task<Model.DatasetEntity> GetDatasetAsync(string name)
104115
{
116+
if (this.client == null)
117+
{
118+
throw new SecurityException("Not Authenticated");
119+
}
120+
105121
var dataset = await this.client.Datasets.GetAsync(
106122
this.configuration.ResourceGroup,
107123
this.configuration.FactoryName,
@@ -118,6 +134,11 @@ public async Task AuthAsync()
118134
/// <returns></returns>
119135
public async Task<Model.DatasetEntity> CreateOrUpdateDatasetAsync(Model.DatasetEntity dataset)
120136
{
137+
if (this.client == null)
138+
{
139+
throw new SecurityException("Not Authenticated");
140+
}
141+
121142
var response = await this.client.Datasets.CreateOrUpdateAsync(
122143
this.configuration.ResourceGroup,
123144
this.configuration.FactoryName,
@@ -139,6 +160,11 @@ public async Task AuthAsync()
139160
/// <returns></returns>
140161
public async Task DeleteDatasetAsync(string name)
141162
{
163+
if (this.client == null)
164+
{
165+
throw new SecurityException("Not Authenticated");
166+
}
167+
142168
var datasetToDelete = await this.GetDatasetAsync(name);
143169
if (datasetToDelete != null)
144170
{
@@ -156,6 +182,11 @@ await this.client.Datasets.DeleteAsync(
156182
/// <returns></returns>
157183
public async Task<Model.DataPipelineEntity> GetPipelineAsync(string name)
158184
{
185+
if (this.client == null)
186+
{
187+
throw new SecurityException("Not Authenticated");
188+
}
189+
159190
var pipeline = await this.client.Pipelines.GetAsync(
160191
this.configuration.ResourceGroup,
161192
this.configuration.FactoryName,
@@ -171,6 +202,11 @@ await this.client.Datasets.DeleteAsync(
171202
/// <returns></returns>
172203
public async Task CreateOrUpdatePipelineyAsync(Model.DataPipelineEntity pipeline)
173204
{
205+
if (this.client == null)
206+
{
207+
throw new SecurityException("Not Authenticated");
208+
}
209+
174210
await this.client.Pipelines.CreateOrUpdateAsync(
175211
this.configuration.ResourceGroup,
176212
this.configuration.FactoryName,
@@ -186,6 +222,11 @@ await this.client.Pipelines.CreateOrUpdateAsync(
186222
/// <returns></returns>
187223
public async Task DeletePipelineAsync(string name)
188224
{
225+
if (this.client == null)
226+
{
227+
throw new SecurityException("Not Authenticated");
228+
}
229+
189230
var pipelineToDelete = await this.GetPipelineAsync(name);
190231
if (pipelineToDelete != null)
191232
{
@@ -204,6 +245,11 @@ await this.client.Pipelines.DeleteAsync(
204245
/// <returns></returns>
205246
public async Task<string> RunPipelineAsync(string pipelineName, Dictionary<string, object> properties = null)
206247
{
248+
if (this.client == null)
249+
{
250+
throw new SecurityException("Not Authenticated");
251+
}
252+
207253
var response = await this.client.Pipelines.CreateRunAsync(
208254
this.configuration.ResourceGroup,
209255
this.configuration.FactoryName,
@@ -220,6 +266,11 @@ public async Task<string> RunPipelineAsync(string pipelineName, Dictionary<strin
220266
/// <returns></returns>
221267
public async Task<Model.DataPipelineRunEntity> GetPipelineRunAsync(string runID)
222268
{
269+
if (this.client == null)
270+
{
271+
throw new SecurityException("Not Authenticated");
272+
}
273+
223274
var run = await this.client.PipelineRuns.GetAsync(
224275
this.configuration.ResourceGroup,
225276
this.configuration.FactoryName,

0 commit comments

Comments
 (0)