/// <summary> /// Update an transformation for a stream analytics job. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.StreamAnalytics.ITransformationOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The resource group name of the stream analytics job. /// </param> /// <param name='jobName'> /// Required. The name of the stream analytics job. /// </param> /// <param name='transformationName'> /// Required. The name of the transformation for the stream analytics /// job. /// </param> /// <param name='parameters'> /// Required. The parameters required to update an transformation for /// the stream analytics job. /// </param> /// <returns> /// The response of the transformation patch operation. /// </returns> public static Task<TransformationPatchResponse> UpdateAsync(this ITransformationOperations operations, string resourceGroupName, string jobName, string transformationName, TransformationPatchParameters parameters) { return operations.UpdateAsync(resourceGroupName, jobName, transformationName, parameters, CancellationToken.None); }
public void Test_TransformationOperations_E2E() { BasicDelegatingHandler handler = new BasicDelegatingHandler(); using (var undoContext = UndoContext.Current) { undoContext.Start(); string resourceGroupName = TestUtilities.GenerateName("StreamAnalytics"); string resourceName = TestUtilities.GenerateName("MyStreamingJobSubmittedBySDK"); string serviceLocation = TestHelper.GetDefaultLocation(); var resourceClient = TestHelper.GetResourceClient(handler); var client = TestHelper.GetStreamAnalyticsManagementClient(handler); try { ResourceGroup resourceGroup = new ResourceGroup() { Location = serviceLocation }; resourceClient.ResourceGroups.CreateOrUpdate(resourceGroupName, resourceGroup); Job job = new Job(); job.Name = resourceName; job.Location = serviceLocation; // Construct the general properties for JobProperties JobProperties jobProperties = new JobProperties(); jobProperties.Sku = new Sku() { Name = "standard" }; jobProperties.EventsOutOfOrderPolicy = EventsOutOfOrderPolicy.Drop; jobProperties.EventsOutOfOrderMaxDelayInSeconds = 0; job.Properties = jobProperties; // Construct the JobCreateProperties JobCreateOrUpdateParameters jobCreateOrUpdateParameters = new JobCreateOrUpdateParameters(); jobCreateOrUpdateParameters.Job = job; // Create a streaming job JobCreateOrUpdateResponse jobCreateOrUpdateResponse = client.StreamingJobs.CreateOrUpdate(resourceGroupName, jobCreateOrUpdateParameters); Assert.Equal(HttpStatusCode.OK, jobCreateOrUpdateResponse.StatusCode); // Get a streaming job to check JobGetParameters jobGetParameters = new JobGetParameters(string.Empty); JobGetResponse jobGetResponse = client.StreamingJobs.Get(resourceGroupName, resourceName, jobGetParameters); Assert.Equal(HttpStatusCode.OK, jobGetResponse.StatusCode); Assert.Equal(serviceLocation, jobGetResponse.Job.Location); Assert.Equal(resourceName, jobGetResponse.Job.Name); // Construct the Transformation string transformationName = TestUtilities.GenerateName("transformationtest"); int numberOfStreamingUnits = 1; Transformation transformation = new Transformation() { Name = transformationName, Properties = new TransformationProperties() { Query = "Select Id, Name from inputtest", StreamingUnits = numberOfStreamingUnits } }; // Add an Transformation TransformationCreateOrUpdateParameters transformationCreateOrUpdateParameters = new TransformationCreateOrUpdateParameters(); transformationCreateOrUpdateParameters.Transformation = transformation; TransformationCreateOrUpdateResponse transformationCreateOrUpdateResponse = client.Transformations.CreateOrUpdate(resourceGroupName, resourceName, transformationCreateOrUpdateParameters); Assert.Equal(HttpStatusCode.OK, transformationCreateOrUpdateResponse.StatusCode); Assert.Equal(numberOfStreamingUnits, transformationCreateOrUpdateResponse.Transformation.Properties.StreamingUnits); Assert.NotNull(transformationCreateOrUpdateResponse.Transformation.Properties.Etag); // Update the Transformation transformation.Properties.StreamingUnits = 3; transformation.Properties.Etag = transformationCreateOrUpdateResponse.Transformation.Properties.Etag; TransformationPatchParameters transformationPatchParameters = new TransformationPatchParameters(transformation.Properties); TransformationPatchResponse transformationPatchResponse = client.Transformations.Patch(resourceGroupName, resourceName, transformationName, transformationPatchParameters); Assert.Equal(HttpStatusCode.OK, transformationPatchResponse.StatusCode); Assert.Equal(3, transformationPatchResponse.Properties.StreamingUnits); Assert.NotNull(transformationPatchResponse.Properties.Etag); Assert.NotEqual(transformationCreateOrUpdateResponse.Transformation.Properties.Etag, transformationPatchResponse.Properties.Etag); } finally { client.StreamingJobs.Delete(resourceGroupName, resourceName); resourceClient.ResourceGroups.Delete(resourceGroupName); } } }
/// <summary> /// Update an transformation for a stream analytics job. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.StreamAnalytics.ITransformationOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The resource group name of the stream analytics job. /// </param> /// <param name='jobName'> /// Required. The name of the stream analytics job. /// </param> /// <param name='transformationName'> /// Required. The name of the transformation for the stream analytics /// job. /// </param> /// <param name='parameters'> /// Required. The parameters required to update an transformation for /// the stream analytics job. /// </param> /// <returns> /// The response of the transformation patch operation. /// </returns> public static TransformationPatchResponse Update(this ITransformationOperations operations, string resourceGroupName, string jobName, string transformationName, TransformationPatchParameters parameters) { return Task.Factory.StartNew((object s) => { return ((ITransformationOperations)s).UpdateAsync(resourceGroupName, jobName, transformationName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }