Пример #1
0
        public PSJob(StreamingJob job)
        {
            if (job == null)
            {
                throw new ArgumentNullException("job");
            }

            this.streamingJob = job;
        }
        public virtual PSJob CreateOrUpdatePSJob(string resourceGroupName, string jobName, string rawJsonContent)
        {
            if (string.IsNullOrWhiteSpace(rawJsonContent))
            {
                throw new ArgumentNullException("rawJsonContent");
            }

            StreamingJob streamingjob = SafeJsonConvert.DeserializeObject <StreamingJob>(
                rawJsonContent,
                StreamAnalyticsClientExtensions.DeserializationSettings);

            // If create failed, the current behavior is to throw
            var response =
                StreamAnalyticsManagementClient.StreamingJobs.CreateOrReplace(
                    streamingjob,
                    resourceGroupName,
                    jobName);

            return(new PSJob(response)
            {
                ResourceGroupName = resourceGroupName
            });
        }
Пример #3
0
        public async Task GetJobAsyncReturnsExpectedJobTest()
        {
            var jobName        = this.random.NextString();
            var jobId          = this.random.NextString();
            var job            = new StreamingJob(id: jobId, name: jobName);
            var jobHeaders     = new StreamingJobsGetHeaders();
            var clientResponse = new AzureOperationResponse <StreamingJob, StreamingJobsGetHeaders>
            {
                Body    = job,
                Headers = jobHeaders,
            };

            this.mockStreamingJobs
            .Setup(x => x.GetWithHttpMessagesAsync(
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <Dictionary <string, List <string> > >(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(clientResponse);

            var jobResponse = await this.helper.GetJobAsync(jobName);

            this.mockStreamingJobs
            .Verify(
                x => x.GetWithHttpMessagesAsync(
                    It.Is <string>(s => s == MockResourceGroup),
                    It.Is <string>(s => s == jobName),
                    It.IsAny <string>(),
                    It.IsAny <Dictionary <string, List <string> > >(),
                    It.IsAny <CancellationToken>()),
                Times.Once);

            Assert.Equal(jobName, jobResponse.Name);
            Assert.Equal(jobId, jobResponse.Id);
        }
Пример #4
0
        public ISg SetParameters(AbstractTraversal t)
        {
            if (!m_isInitialized)
            {
                var info = m_instance.PatchFileInfo;
                var bb   = m_instance.PositionsType == PositionsType.V3dPositions ?
                           info.LocalBoundingBox : info.LocalBoundingBox2d;

                var patch = new StreamingJob(
                    () =>
                {
                    //TaskCombinators.Delay(100);
                    //do importer logic here

                    var patchVg = m_instance.LoadingStrategy.Load(m_instance.PatchFileInfo, m_instance.PatchFilePath, m_instance.PositionsType,
                                                                  true, true, true, m_instance.MaxTriangleSize);

                    if (patchVg == null)
                    {
                        return(EmptyLeaf.Singleton);
                    }

                    var lodColor        = Patch.GetLodColor(m_instance.Level, m_instance.MaxLevel);
                    patchVg["LodColor"] = lodColor;

                    for (int i = 0; i < patchVg.Textures.Count; i++)
                    {
                        var key = patchVg.Textures.Keys.ToList()[i];

                        var source         = patchVg.Textures[key].Convertible;
                        Convertible target = null;

                        if (t.Renderer is SlimDx9Renderer)
                        {
                            target = SlimDx9TextureConvertible.Create(
                                new SlimDx9TextureConvertible.SlimDx9TextureParameters()
                            {
                                //SlimDx9Format = SlimDX.Direct3D9.Format., // .Dxt5,
                                Pool = SlimDX.Direct3D9.Pool.Default
                            });
                            source.ConvertInto(target);
                        }
                        else
                        {
                            // nothing todo in slimdx10renderer (this just loads the texture on demand)
                            // fix this if you are fed up with framerate hick ups
                            target = source;
                        }

                        patchVg.Textures[key] = new Texture(target);
                    }
                    lock (asyncLock)
                    {
                        m_asyncTextures = patchVg.Textures;
                    }

                    return(patchVg.ToVertexGeometrySet());
                },
                    bb, m_instance.MaxLevel - m_instance.Level, true);

                patch.DestructSideEffects = DisposeSideEffects;

                var placeHolder = Primitives.WireBox(bb, C4b.Red).ToVertexGeometrySet();

                m_returnISg = new AsyncStreamingNode(patch, placeHolder)
                {
                    DebugName = Path.GetFileName(m_instance.PatchFilePath),
                };

                var local2Global = m_instance.PatchFileInfo.GetLocal2Global(m_instance.PositionsType);

                if (m_instance.InvertZ)
                {
                    local2Global = M44d.Scale(1, 1, -1) * local2Global;
                }

                var global2Local = local2Global.Inverse;
                m_returnISg = Rsg.Apply(Rsg.Attribute.PushTrafo3d(new Trafo3d(local2Global, global2Local)), m_returnISg);

                m_isInitialized = true;
            }

            return(m_returnISg);
        }
Пример #5
0
        public async Task StreamingJobOperationsTest_JobShell()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                string resourceGroupName = TestUtilities.GenerateName("sjrg");
                string jobName           = TestUtilities.GenerateName("sj");

                var resourceManagementClient        = this.GetResourceManagementClient(context);
                var streamAnalyticsManagementClient = this.GetStreamAnalyticsManagementClient(context);

                string expectedJobResourceId = TestHelper.GetJobResourceId(streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, jobName);

                resourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup {
                    Location = TestHelper.DefaultLocation
                });

                StreamingJob streamingJob = new StreamingJob()
                {
                    Tags = new Dictionary <string, string>()
                    {
                        { "key1", "value1" },
                        { "randomKey", "randomValue" },
                        { "key3", "value3" }
                    },
                    Location = TestHelper.DefaultLocation,
                    EventsOutOfOrderPolicy             = EventsOutOfOrderPolicy.Drop,
                    EventsOutOfOrderMaxDelayInSeconds  = 5,
                    EventsLateArrivalMaxDelayInSeconds = 16,
                    OutputErrorPolicy  = OutputErrorPolicy.Drop,
                    DataLocale         = "en-US",
                    CompatibilityLevel = CompatibilityLevel.OneFullStopZero,
                    Sku = new Microsoft.Azure.Management.StreamAnalytics.Models.Sku()
                    {
                        Name = SkuName.Standard
                    },
                    Inputs    = new List <Input>(),
                    Outputs   = new List <Output>(),
                    Functions = new List <Function>()
                };

                // PUT job
                var putResponse = await streamAnalyticsManagementClient.StreamingJobs.CreateOrReplaceWithHttpMessagesAsync(streamingJob, resourceGroupName, jobName);

                ValidationHelper.ValidateStreamingJob(streamingJob, putResponse.Body, false);
                Assert.Equal(expectedJobResourceId, putResponse.Body.Id);
                Assert.Equal(jobName, putResponse.Body.Name);
                Assert.Equal(TestHelper.StreamingJobFullResourceType, putResponse.Body.Type);

                Assert.Equal("Succeeded", putResponse.Body.ProvisioningState);
                Assert.Equal("Created", putResponse.Body.JobState);

                // Verify GET request returns expected job
                var getResponse = await streamAnalyticsManagementClient.StreamingJobs.GetWithHttpMessagesAsync(resourceGroupName, jobName, "inputs,outputs,transformation,functions");

                ValidationHelper.ValidateStreamingJob(putResponse.Body, getResponse.Body, true);
                // ETag should be the same
                Assert.Equal(putResponse.Headers.ETag, getResponse.Headers.ETag);

                // PATCH job
                var streamingJobPatch = new StreamingJob()
                {
                    EventsOutOfOrderMaxDelayInSeconds  = 21,
                    EventsLateArrivalMaxDelayInSeconds = 13
                };
                putResponse.Body.EventsOutOfOrderMaxDelayInSeconds  = streamingJobPatch.EventsOutOfOrderMaxDelayInSeconds;
                putResponse.Body.EventsLateArrivalMaxDelayInSeconds = streamingJobPatch.EventsLateArrivalMaxDelayInSeconds;
                putResponse.Body.Inputs    = null;
                putResponse.Body.Outputs   = null;
                putResponse.Body.Functions = null;
                var patchResponse = await streamAnalyticsManagementClient.StreamingJobs.UpdateWithHttpMessagesAsync(streamingJobPatch, resourceGroupName, jobName);

                ValidationHelper.ValidateStreamingJob(putResponse.Body, patchResponse.Body, true);
                // ETag should be different after a PATCH operation
                Assert.NotEqual(putResponse.Headers.ETag, patchResponse.Headers.ETag);

                putResponse.Body.Inputs    = new List <Input>();
                putResponse.Body.Outputs   = new List <Output>();
                putResponse.Body.Functions = new List <Function>();
                // Run another GET job to verify that it returns the newly updated properties as well
                getResponse = await streamAnalyticsManagementClient.StreamingJobs.GetWithHttpMessagesAsync(resourceGroupName, jobName, "inputs,outputs,transformation,functions");

                ValidationHelper.ValidateStreamingJob(putResponse.Body, getResponse.Body, true);
                Assert.NotEqual(putResponse.Headers.ETag, getResponse.Headers.ETag);
                Assert.Equal(patchResponse.Headers.ETag, getResponse.Headers.ETag);

                // List job and verify that the job shows up in the list
                var listByRgResponse = streamAnalyticsManagementClient.StreamingJobs.ListByResourceGroup(resourceGroupName, "inputs,outputs,transformation,functions");
                Assert.Single(listByRgResponse);
                ValidationHelper.ValidateStreamingJob(putResponse.Body, listByRgResponse.Single(), true);
                Assert.Equal(getResponse.Headers.ETag, listByRgResponse.Single().Etag);

                var listReponse = streamAnalyticsManagementClient.StreamingJobs.List("inputs, outputs, transformation, functions");
                Assert.Single(listReponse);
                ValidationHelper.ValidateStreamingJob(putResponse.Body, listReponse.Single(), true);
                Assert.Equal(getResponse.Headers.ETag, listReponse.Single().Etag);

                // Delete job
                streamAnalyticsManagementClient.StreamingJobs.Delete(resourceGroupName, jobName);

                // Verify that list operation returns an empty list after deleting the job
                listByRgResponse = streamAnalyticsManagementClient.StreamingJobs.ListByResourceGroup(resourceGroupName, "inputs,outputs,transformation,functions");
                Assert.Empty(listByRgResponse);

                listReponse = streamAnalyticsManagementClient.StreamingJobs.List("inputs, outputs, transformation, functions");
                Assert.Empty(listReponse);
            }
        }
Пример #6
0
        public async Task StreamingJobOperationsTest_FullJob()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                string resourceGroupName  = TestUtilities.GenerateName("sjrg");
                string jobName            = TestUtilities.GenerateName("sj");
                string inputName          = "inputtest";
                string transformationName = "transformationtest";
                string outputName         = "outputtest";

                var resourceManagementClient        = this.GetResourceManagementClient(context);
                var streamAnalyticsManagementClient = this.GetStreamAnalyticsManagementClient(context);

                string expectedJobResourceId            = TestHelper.GetJobResourceId(streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, jobName);
                string expectedInputResourceId          = TestHelper.GetRestOnlyResourceId(streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, jobName, TestHelper.InputsResourceType, inputName);
                string expectedTransformationResourceId = TestHelper.GetRestOnlyResourceId(streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, jobName, TestHelper.TransformationResourceType, transformationName);
                string expectedOutputResourceId         = TestHelper.GetRestOnlyResourceId(streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, jobName, TestHelper.OutputsResourceType, outputName);

                resourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup {
                    Location = TestHelper.DefaultLocation
                });

                StorageAccount storageAccount = new StorageAccount()
                {
                    AccountName = TestHelper.AccountName,
                    AccountKey  = TestHelper.AccountKey
                };
                Input input = new Input(id: expectedInputResourceId)
                {
                    Name       = inputName,
                    Properties = new StreamInputProperties()
                    {
                        Serialization = new JsonSerialization()
                        {
                            Encoding = Encoding.UTF8
                        },
                        Datasource = new BlobStreamInputDataSource()
                        {
                            StorageAccounts = new[] { storageAccount },
                            Container       = TestHelper.Container,
                            PathPattern     = "",
                        }
                    }
                };

                AzureSqlDatabaseOutputDataSource azureSqlDatabase = new AzureSqlDatabaseOutputDataSource()
                {
                    Server   = TestHelper.Server,
                    Database = TestHelper.Database,
                    User     = TestHelper.User,
                    Password = TestHelper.Password,
                    Table    = TestHelper.SqlTableName
                };
                Output output = new Output(id: expectedOutputResourceId)
                {
                    Name       = outputName,
                    Datasource = azureSqlDatabase
                };

                StreamingJob streamingJob = new StreamingJob()
                {
                    Tags = new Dictionary <string, string>()
                    {
                        { "key1", "value1" },
                        { "randomKey", "randomValue" },
                        { "key3", "value3" }
                    },
                    Location = TestHelper.DefaultLocation,
                    EventsOutOfOrderPolicy             = EventsOutOfOrderPolicy.Drop,
                    EventsOutOfOrderMaxDelayInSeconds  = 0,
                    EventsLateArrivalMaxDelayInSeconds = 5,
                    OutputErrorPolicy  = OutputErrorPolicy.Drop,
                    DataLocale         = "en-US",
                    CompatibilityLevel = "1.0",
                    Sku = new Microsoft.Azure.Management.StreamAnalytics.Models.Sku()
                    {
                        Name = SkuName.Standard
                    },
                    Inputs = new List <Input>()
                    {
                        input
                    },
                    Transformation = new Transformation(id: expectedTransformationResourceId)
                    {
                        Name           = transformationName,
                        Query          = "Select Id, Name from inputtest",
                        StreamingUnits = 1
                    },
                    Outputs = new List <Output>()
                    {
                        output
                    },
                    Functions = new List <Function>()
                };

                // PUT job
                var putResponse = await streamAnalyticsManagementClient.StreamingJobs.CreateOrReplaceWithHttpMessagesAsync(streamingJob, resourceGroupName, jobName);

                // Null out because secrets are not returned in responses
                storageAccount.AccountKey = null;
                azureSqlDatabase.Password = null;
                ValidationHelper.ValidateStreamingJob(streamingJob, putResponse.Body, false);
                Assert.Equal(expectedJobResourceId, putResponse.Body.Id);
                Assert.Equal(jobName, putResponse.Body.Name);
                Assert.Equal(TestHelper.StreamingJobFullResourceType, putResponse.Body.Type);
                //Assert.True(putResponse.Body.CreatedDate > DateTime.UtcNow.AddMinutes(-1));

                Assert.Equal("Succeeded", putResponse.Body.ProvisioningState);
                Assert.Equal("Created", putResponse.Body.JobState);

                // Verify GET request returns expected job
                var getResponse = await streamAnalyticsManagementClient.StreamingJobs.GetWithHttpMessagesAsync(resourceGroupName, jobName, "inputs,outputs,transformation,functions");

                ValidationHelper.ValidateStreamingJob(putResponse.Body, getResponse.Body, true);
                // ETag should be the same
                Assert.Equal(putResponse.Headers.ETag, getResponse.Headers.ETag);

                // PATCH job
                var streamingJobPatch = new StreamingJob()
                {
                    EventsOutOfOrderPolicy = EventsOutOfOrderPolicy.Adjust,
                    OutputErrorPolicy      = OutputErrorPolicy.Stop
                };
                putResponse.Body.EventsOutOfOrderPolicy = streamingJobPatch.EventsOutOfOrderPolicy;
                putResponse.Body.OutputErrorPolicy      = streamingJobPatch.OutputErrorPolicy;
                putResponse.Body.Functions          = null;
                streamingJob.EventsOutOfOrderPolicy = streamingJobPatch.EventsOutOfOrderPolicy;
                streamingJob.OutputErrorPolicy      = streamingJobPatch.OutputErrorPolicy;
                streamingJob.Inputs         = null;
                streamingJob.Transformation = null;
                streamingJob.Outputs        = null;
                streamingJob.Functions      = null;
                var patchResponse = await streamAnalyticsManagementClient.StreamingJobs.UpdateWithHttpMessagesAsync(streamingJobPatch, resourceGroupName, jobName);

                ValidationHelper.ValidateStreamingJob(streamingJob, patchResponse.Body, false);
                // ETag should be different after a PATCH operation
                Assert.NotEqual(putResponse.Headers.ETag, patchResponse.Headers.ETag);

                putResponse.Body.Functions = new List <Function>();
                // Run another GET job to verify that it returns the newly updated properties as well
                getResponse = await streamAnalyticsManagementClient.StreamingJobs.GetWithHttpMessagesAsync(resourceGroupName, jobName, "inputs,outputs,transformation,functions");

                ValidationHelper.ValidateStreamingJob(putResponse.Body, getResponse.Body, true);
                Assert.NotEqual(putResponse.Headers.ETag, getResponse.Headers.ETag);
                Assert.Equal(patchResponse.Headers.ETag, getResponse.Headers.ETag);

                // List job and verify that the job shows up in the list
                var listByRgResponse = streamAnalyticsManagementClient.StreamingJobs.ListByResourceGroup(resourceGroupName, "inputs,outputs,transformation,functions");
                Assert.Single(listByRgResponse);
                ValidationHelper.ValidateStreamingJob(putResponse.Body, listByRgResponse.Single(), true);
                Assert.Equal(getResponse.Headers.ETag, listByRgResponse.Single().Etag);

                var listReponse = streamAnalyticsManagementClient.StreamingJobs.List("inputs, outputs, transformation, functions");
                Assert.Single(listReponse);
                ValidationHelper.ValidateStreamingJob(putResponse.Body, listReponse.Single(), true);
                Assert.Equal(getResponse.Headers.ETag, listReponse.Single().Etag);

                // Start job
                StartStreamingJobParameters startStreamingJobParameters = new StartStreamingJobParameters()
                {
                    OutputStartMode = OutputStartMode.LastOutputEventTime
                };
                CloudException cloudException = Assert.Throws <CloudException>(() => streamAnalyticsManagementClient.StreamingJobs.Start(resourceGroupName, jobName, startStreamingJobParameters));
                Assert.Equal((HttpStatusCode)422, cloudException.Response.StatusCode);
                Assert.Contains("LastOutputEventTime must be available when OutputStartMode is set to LastOutputEventTime. Please make sure at least one output event has been processed.", cloudException.Response.Content);

                startStreamingJobParameters.OutputStartMode = OutputStartMode.CustomTime;
                startStreamingJobParameters.OutputStartTime = new DateTime(2012, 12, 12, 12, 12, 12, DateTimeKind.Utc);
                putResponse.Body.OutputStartMode            = startStreamingJobParameters.OutputStartMode;
                putResponse.Body.OutputStartTime            = startStreamingJobParameters.OutputStartTime;
                streamingJob.OutputStartMode = startStreamingJobParameters.OutputStartMode;
                streamingJob.OutputStartTime = startStreamingJobParameters.OutputStartTime;
                streamAnalyticsManagementClient.StreamingJobs.Start(resourceGroupName, jobName, startStreamingJobParameters);

                // Check that job started
                var getResponseAfterStart = await streamAnalyticsManagementClient.StreamingJobs.GetWithHttpMessagesAsync(resourceGroupName, jobName);

                Assert.Equal("Succeeded", getResponseAfterStart.Body.ProvisioningState);
                Assert.True(getResponseAfterStart.Body.JobState == "Running" || getResponseAfterStart.Body.JobState == "Degraded");
                Assert.Null(getResponseAfterStart.Body.Inputs);
                Assert.Null(getResponseAfterStart.Body.Transformation);
                Assert.Null(getResponseAfterStart.Body.Outputs);
                Assert.Null(getResponseAfterStart.Body.Functions);
                ValidationHelper.ValidateStreamingJob(streamingJob, getResponseAfterStart.Body, false);
                Assert.NotEqual(putResponse.Headers.ETag, getResponseAfterStart.Headers.ETag);
                Assert.NotEqual(patchResponse.Headers.ETag, getResponseAfterStart.Headers.ETag);

                // Check diagnostics
                var inputListResponse = streamAnalyticsManagementClient.Inputs.ListByStreamingJob(resourceGroupName, jobName, "*");
                Assert.NotNull(inputListResponse);
                Assert.Single(inputListResponse);
                var inputFromList = inputListResponse.Single();
                Assert.NotNull(inputFromList.Properties.Diagnostics);
                Assert.Equal(2, inputFromList.Properties.Diagnostics.Conditions.Count());
                Assert.NotNull(inputFromList.Properties.Diagnostics.Conditions[0].Since);
                DateTime.Parse(inputFromList.Properties.Diagnostics.Conditions[0].Since);
                Assert.Equal(@"INP-3", inputFromList.Properties.Diagnostics.Conditions[0].Code);
                Assert.Equal(@"Could not deserialize the input event(s) from resource 'https://$testAccountName$.blob.core.windows.net/state/states1.csv' as Json. Some possible reasons: 1) Malformed events 2) Input source configured with incorrect serialization format", inputFromList.Properties.Diagnostics.Conditions[0].Message);

                // Stop job
                streamAnalyticsManagementClient.StreamingJobs.Stop(resourceGroupName, jobName);

                // Check that job stopped
                var getResponseAfterStop = await streamAnalyticsManagementClient.StreamingJobs.GetWithHttpMessagesAsync(resourceGroupName, jobName, "inputs,outputs,transformation,functions");

                Assert.Equal("Succeeded", getResponseAfterStop.Body.ProvisioningState);
                Assert.Equal("Stopped", getResponseAfterStop.Body.JobState);
                ValidationHelper.ValidateStreamingJob(putResponse.Body, getResponseAfterStop.Body, false);
                Assert.NotEqual(putResponse.Headers.ETag, getResponseAfterStop.Headers.ETag);
                Assert.NotEqual(patchResponse.Headers.ETag, getResponseAfterStop.Headers.ETag);
                Assert.NotEqual(getResponseAfterStart.Headers.ETag, getResponseAfterStop.Headers.ETag);

                // Delete job
                streamAnalyticsManagementClient.StreamingJobs.Delete(resourceGroupName, jobName);

                // Verify that list operation returns an empty list after deleting the job
                listByRgResponse = streamAnalyticsManagementClient.StreamingJobs.ListByResourceGroup(resourceGroupName, "inputs,outputs,transformation,functions");
                Assert.Empty(listByRgResponse);

                listReponse = streamAnalyticsManagementClient.StreamingJobs.List("inputs, outputs, transformation, functions");
                Assert.Empty(listReponse);
            }
        }
Пример #7
0
 public PSJob()
 {
     streamingJob = new StreamingJob();
 }
Пример #8
0
        static void Main(string[] args)
        {
            string AzureresourceGroupName = "<<Your Azure Resource Group Name>>";
            string AzurestreamingJobName  = "<<Your Azure ASA job name>>";
            string ASAinputName           = "<<Your ASA job Input>>";
            string ASAtransformationName  = "<<Your ASA Job Transformation Name>>";
            string ASAoutputName          = "<<Your ASA job output Name>>";

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            // Get credentials
            ServiceClientCredentials credentials = GetAzureCredentials().Result;

            // Create Stream Analytics management client
            StreamAnalyticsManagementClient streamAnalyticsManagementClient = new StreamAnalyticsManagementClient(credentials)
            {
                SubscriptionId = ConfigurationManager.AppSettings["SubscriptionId"]
            };

            // Create Azure  streaming job
            StreamingJob streamingJob = new StreamingJob()
            {
                Tags = new Dictionary <string, string>()
                {
                    { "Origin", ".NET SDK" },
                    { "ReasonCreated", "Stream Analytics Job Provision Using .NET Management SDK" }
                },
                Location = "East Asia",
                EventsOutOfOrderPolicy             = EventsOutOfOrderPolicy.Adjust,
                EventsOutOfOrderMaxDelayInSeconds  = 2,
                EventsLateArrivalMaxDelayInSeconds = 16,
                OutputErrorPolicy  = OutputErrorPolicy.Stop,
                DataLocale         = "en-US",
                CompatibilityLevel = CompatibilityLevel.OneFullStopZero,
                Sku = new Sku()
                {
                    Name = SkuName.Standard
                }
            };
            StreamingJob createNewStreamingJobResult = streamAnalyticsManagementClient.StreamingJobs.CreateOrReplace(streamingJob, AzureresourceGroupName, AzurestreamingJobName);


            // Create an input
            StorageAccount storageAccount = new StorageAccount()
            {
                AccountName = "<<Your Azure Storage Account Name>>",
                AccountKey  = "<<Azure Storage Account Key>>"
            };
            Input input = new Input()
            {
                Properties = new StreamInputProperties()
                {
                    Serialization = new CsvSerialization()
                    {
                        FieldDelimiter = ",",
                        Encoding       = Microsoft.Azure.Management.StreamAnalytics.Models.Encoding.UTF8
                    },
                    Datasource = new BlobStreamInputDataSource()
                    {
                        StorageAccounts      = new[] { storageAccount },
                        Container            = "<<Your Storage Account Container>>",
                        PathPattern          = "{date}/{time}",
                        DateFormat           = "yyyy/MM/dd",
                        TimeFormat           = "HH",
                        SourcePartitionCount = 16
                    }
                }
            };
            Input createInputResult = streamAnalyticsManagementClient.Inputs.CreateOrReplace(input, AzureresourceGroupName, AzurestreamingJobName, ASAinputName);
            // Test the connection to the input
            ResourceTestStatus testInputResult = streamAnalyticsManagementClient.Inputs.Test(AzureresourceGroupName, AzurestreamingJobName, ASAinputName);


            // Create an output
            Output output = new Output()
            {
                Datasource = new AzureSqlDatabaseOutputDataSource()
                {
                    Server   = "<<Your Azure SQL Database Server>>",
                    Database = "<<Your Azure SQL db name>>",
                    User     = "******",
                    Password = "******",
                    Table    = "<<Your Azure SQL db table>>"
                }
            };
            Output createOutputResult = streamAnalyticsManagementClient.Outputs.CreateOrReplace(output, AzureresourceGroupName, AzurestreamingJobName, ASAoutputName);
            // Create a transformation
            Transformation transformation = new Transformation()
            {
                Query          = "Select Id, Name from input", // '<your input name>' should be replaced with the value you put for the 'inputName' variable above or in a previous step
                StreamingUnits = 1
            };
            Transformation createTransformationResult = streamAnalyticsManagementClient.Transformations.CreateOrReplace(transformation, AzureresourceGroupName, AzurestreamingJobName, ASAtransformationName);


            // Start a streaming job
            StartStreamingJobParameters startStreamingJobParameters = new StartStreamingJobParameters()
            {
                OutputStartMode = OutputStartMode.CustomTime,
                OutputStartTime = new DateTime(2017, 10, 12, 12, 12, 12, DateTimeKind.Utc)
            };

            streamAnalyticsManagementClient.StreamingJobs.Start(AzureresourceGroupName, AzurestreamingJobName, startStreamingJobParameters);

            // Stop a streaming job
            streamAnalyticsManagementClient.StreamingJobs.Stop(AzureresourceGroupName, AzurestreamingJobName);

            // Delete a streaming job
            //   streamAnalyticsManagementClient.StreamingJobs.Delete(resourceGroupName, streamingJobName);
        }
Пример #9
0
 /// <summary>
 /// Creates a streaming job or replaces an already existing streaming job.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='streamingJob'>
 /// The definition of the streaming job that will be used to create a new
 /// streaming job or replace the existing one.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='jobName'>
 /// The name of the streaming job.
 /// </param>
 /// <param name='ifMatch'>
 /// The ETag of the streaming job. Omit this value to always overwrite the
 /// current record set. Specify the last-seen ETag value to prevent
 /// accidentally overwriting concurrent changes.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Set to '*' to allow a new streaming job to be created, but to prevent
 /// updating an existing record set. Other values will result in a 412
 /// Pre-condition Failed response.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <StreamingJob> CreateOrReplaceAsync(this IStreamingJobsOperations operations, StreamingJob streamingJob, string resourceGroupName, string jobName, string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrReplaceWithHttpMessagesAsync(streamingJob, resourceGroupName, jobName, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #10
0
 /// <summary>
 /// Creates a streaming job or replaces an already existing streaming job.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='streamingJob'>
 /// The definition of the streaming job that will be used to create a new
 /// streaming job or replace the existing one.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='jobName'>
 /// The name of the streaming job.
 /// </param>
 /// <param name='ifMatch'>
 /// The ETag of the streaming job. Omit this value to always overwrite the
 /// current record set. Specify the last-seen ETag value to prevent
 /// accidentally overwriting concurrent changes.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Set to '*' to allow a new streaming job to be created, but to prevent
 /// updating an existing record set. Other values will result in a 412
 /// Pre-condition Failed response.
 /// </param>
 public static StreamingJob CreateOrReplace(this IStreamingJobsOperations operations, StreamingJob streamingJob, string resourceGroupName, string jobName, string ifMatch = default(string), string ifNoneMatch = default(string))
 {
     return(operations.CreateOrReplaceAsync(streamingJob, resourceGroupName, jobName, ifMatch, ifNoneMatch).GetAwaiter().GetResult());
 }
Пример #11
0
 public static string ToFormattedString(this StreamingJob properties)
 {
     return(SafeJsonConvert.SerializeObject(properties, SerializationSettings));
 }
Пример #12
0
 public void JobIsActiveReturnsExpectedValueTest(StreamingJob job, bool expectedValue)
 {
     Assert.Equal(expectedValue, this.helper.JobIsActive(job));
 }
 public bool JobIsActive(StreamingJob job)
 {
     return(job.JobState == "Running" || job.JobState == "Starting");
 }