/// <summary>
 /// Retrieve the default definition of a function for a stream
 /// analytics job. The raw json content will be used for the request
 /// body.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.StreamAnalytics.IFunctionOperations.
 /// </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='functionName'>
 /// Required. The name of the function for the stream analytics job.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters required to retrieve the default
 /// definition of a function for a stream analytics job.
 /// </param>
 /// <returns>
 /// The response of the retrieve default function definition operation.
 /// </returns>
 public static Task<FunctionRetrieveDefaultDefinitionResponse> RetrieveDefaultDefinitionWithRawJsonContentAsync(this IFunctionOperations operations, string resourceGroupName, string jobName, string functionName, FunctionRetrieveDefaultDefinitionWithRawJsonContentParameters parameters)
 {
     return operations.RetrieveDefaultDefinitionWithRawJsonContentAsync(resourceGroupName, jobName, functionName, parameters, CancellationToken.None);
 }
        public void Test_FunctionOperations_RetrieveDefaultDefinitionWithRawJsonContent()
        {
            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);

                    // Construct the JobCreateProperties
                    JobCreateOrUpdateParameters jobCreateOrUpdateParameters =
                        new JobCreateOrUpdateParameters(TestHelper.GetDefaultJob(resourceName, serviceLocation));

                    // 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);

                    // Retrieve default definition of the function
                    string functionName = TestUtilities.GenerateName("functiontest");
                    string content = File.ReadAllText(@"Resources\RetrieveDefaultFunctionDefinitionRequest.json");
                    var retrieveDefaultDefinitionParameters = new FunctionRetrieveDefaultDefinitionWithRawJsonContentParameters
                        ()
                    {
                        Content = content
                    };
                    FunctionRetrieveDefaultDefinitionResponse retrieveDefaultDefinitionResponse =
                        client.Functions.RetrieveDefaultDefinitionWithRawJsonContent(resourceGroupName, resourceName, functionName,
                            retrieveDefaultDefinitionParameters);
                    Assert.Equal(functionName, retrieveDefaultDefinitionResponse.Function.Name);
                    ScalarFunctionProperties scalarFunctionProperties =
                        (ScalarFunctionProperties)retrieveDefaultDefinitionResponse.Function.Properties;
                    AzureMachineLearningWebServiceFunctionBinding azureMachineLearningWebServiceFunctionBinding =
                        (AzureMachineLearningWebServiceFunctionBinding)scalarFunctionProperties.Properties.Binding;
                    Assert.Equal(TestHelper.ExecuteEndpoint, azureMachineLearningWebServiceFunctionBinding.Properties.Endpoint);
                    Assert.Equal(1000, azureMachineLearningWebServiceFunctionBinding.Properties.BatchSize);
                    Assert.Null(azureMachineLearningWebServiceFunctionBinding.Properties.ApiKey);
                    azureMachineLearningWebServiceFunctionBinding.Properties.ApiKey = TestHelper.ApiKey;
                }
                finally
                {
                    client.StreamingJobs.Delete(resourceGroupName, resourceName);
                    resourceClient.ResourceGroups.Delete(resourceGroupName);
                }
            }
        }
 /// <summary>
 /// Retrieve the default definition of a function for a stream
 /// analytics job. The raw json content will be used for the request
 /// body.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.StreamAnalytics.IFunctionOperations.
 /// </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='functionName'>
 /// Required. The name of the function for the stream analytics job.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters required to retrieve the default
 /// definition of a function for a stream analytics job.
 /// </param>
 /// <returns>
 /// The response of the retrieve default function definition operation.
 /// </returns>
 public static FunctionRetrieveDefaultDefinitionResponse RetrieveDefaultDefinitionWithRawJsonContent(this IFunctionOperations operations, string resourceGroupName, string jobName, string functionName, FunctionRetrieveDefaultDefinitionWithRawJsonContentParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IFunctionOperations)s).RetrieveDefaultDefinitionWithRawJsonContentAsync(resourceGroupName, jobName, functionName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }