Exemplo n.º 1
0
        public static void createUpdateTrigger(DataFactoryManagementClient client)
        {
            TriggerPipelineReference[] triPipe;
            string[] tablas = DatosGrales.traerTablas(true);
            for (int o = 1; o < (tablas.Length) / 10; o++)
            {
                if (o != Convert.ToInt32(tablas.Length / 10))
                {
                    triPipe = new TriggerPipelineReference[o * 10];//tablas.Length
                }
                else
                {
                    triPipe = new TriggerPipelineReference[tablas.Length];
                }

                PipelineReference pipe;
                for (int i = 0; i < triPipe.Length; i++)
                {
                    if (!tablas[i].Contains("ccst"))
                    {
                        pipe       = new PipelineReference("Pipeline-Sql-DataLake-ConCompresion-Claim-" + tablas[i], "Pipeline-Sql-DataLake-ConCompresion-Claim-" + tablas[i]);
                        triPipe[i] = new TriggerPipelineReference(pipe);

                        //Agrego parametro dummy porque en realidad no uso, pero es obligatorio tener.
                        Dictionary <String, object> diccionarioParams = new Dictionary <String, object>();
                        diccionarioParams.Add("Param1", 1);
                        triPipe[i].Parameters = diccionarioParams;
                    }
                }
                DateTime hoy = DateTime.Now.AddDays(-2);
                DateTime fin = hoy.AddDays(15);
                ScheduleTriggerRecurrence str = new ScheduleTriggerRecurrence(null, "Day", 1, hoy, fin);
                str.TimeZone = "UTC";

                ScheduleTrigger schedule = new ScheduleTrigger(str, null, "Trigger para pipes con compresion", "Stopped", triPipe);

                TriggerResource trig = new TriggerResource(schedule, null, "CompresionSinCCST", "ScheduleTrigger");
                //trig.Proper
                try
                {
                    TriggerResource trig1 = client.Triggers.CreateOrUpdate(DatosGrales.resourceGroup, DatosGrales.dataFactoryName, "CompresionSinCCST", trig);
                    Console.WriteLine("Trigger creado con " + (o * 10) + " pipelines, a ver si se banca mas?");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Trigger con " + (o * 10) + " pipelines fallo, hacemos otro intento...");
                    o--;
                }
            }
            //var aor = client.Triggers.StartWithHttpMessagesAsync(resourceGroup, dataFactoryName, "Trigger prueba tarea");
        }
        private List <TriggerPipelineReference> GetPipelineForScheduleTrigger(List <Pipeline> pipelines)
        {
            List <TriggerPipelineReference> pipelineReferences = new List <TriggerPipelineReference>();

            foreach (Pipeline pipeline in pipelines)
            {
                TriggerPipelineReference reference = new TriggerPipelineReference()
                {
                    PipelineReference = new PipelineReference(pipeline.Name)
                };
                if (pipeline.PipelineParams != null && pipeline.PipelineParams.Count > 0)
                {
                    reference.Parameters = pipeline.PipelineParams;
                }
                pipelineReferences.Add(reference);
            }
            return(pipelineReferences);
        }
Exemplo n.º 3
0
        public static void createUpdateTrigger1(DataFactoryManagementClient client)
        {
            TriggerPipelineReference[] triPipe;
            string[] tablas = DatosGrales.traerTablas(true);
            triPipe = new TriggerPipelineReference[5];
            PipelineReference pipe;

            for (int i = 0; i < triPipe.Length; i++)
            {
                if (!tablas[i].Contains("ccst"))
                {
                    pipe       = new PipelineReference("Pipeline-Sql-DataLake-ConCompresion-Claim-" + tablas[i], "Pipeline-Sql-DataLake-ConCompresion-Claim-" + tablas[i]);
                    triPipe[i] = new TriggerPipelineReference(pipe);

                    //Agrego parametro dummy porque en realidad no uso, pero es obligatorio tener.
                    Dictionary <String, object> diccionarioParams = new Dictionary <String, object>();
                    diccionarioParams.Add("Param1", 1);
                    triPipe[i].Parameters = diccionarioParams;
                }
            }
            DateTime hoy = DateTime.Now.AddDays(-2);
            DateTime fin = hoy.AddDays(15);
            ScheduleTriggerRecurrence str = new ScheduleTriggerRecurrence(null, "Day", 1, hoy, fin);

            str.TimeZone = "UTC";

            ScheduleTrigger schedule = new ScheduleTrigger(str, null, "Trigger para pipes con compresion", "Stopped", triPipe);

            TriggerResource trig = new TriggerResource(schedule, null, "CompresionSinCCST", "ScheduleTrigger");

            //trig.Proper
            try
            {
                TriggerResource trig1 = client.Triggers.CreateOrUpdate(DatosGrales.resourceGroup, DatosGrales.dataFactoryName, "CompresionSinCCST1", trig);
                Console.WriteLine("Trigger creado!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Trigger fallo al crearse =(");
            }
        }
        internal static TriggerResource GetTriggerResource(string description, string pipelineName, string outputBlobName)
        {
            TriggerResource resource = new TriggerResource()
            {
                Properties = new ScheduleTrigger()
                {
                    Description = description,
                    Recurrence  = new ScheduleTriggerRecurrence()
                    {
                        TimeZone  = "UTC",
                        StartTime = DateTime.UtcNow.AddMinutes(-1),
                        EndTime   = DateTime.UtcNow.AddMinutes(15),
                        Frequency = RecurrenceFrequency.Minute,
                        Interval  = 4,
                        Schedule  = null
                    },
                    Pipelines = new List <TriggerPipelineReference>()
                }
            };

            TriggerPipelineReference triggerPipelineReference = new TriggerPipelineReference()
            {
                PipelineReference = new PipelineReference(pipelineName),
                Parameters        = new Dictionary <string, object>()
            };

            string[] outputBlobNameList = new string[1];
            outputBlobNameList[0] = outputBlobName;

            JArray outputBlobNameArray = JArray.FromObject(outputBlobNameList);

            triggerPipelineReference.Parameters.Add("OutputBlobNameList", outputBlobNameArray);

            ((ScheduleTrigger)(resource.Properties)).Pipelines.Add(triggerPipelineReference);

            return(resource);
        }
Exemplo n.º 5
0
        private TriggerResource GetTWTriggerResource(string description)
        {
            TriggerResource resource = new TriggerResource()
            {
                Properties = new TumblingWindowTrigger()
                {
                    Description    = description,
                    StartTime      = DateTime.UtcNow.AddMinutes(-10),
                    EndTime        = DateTime.UtcNow.AddMinutes(5),
                    Frequency      = RecurrenceFrequency.Minute,
                    Interval       = 1,
                    Delay          = "00:00:01",
                    MaxConcurrency = 1,
                    RetryPolicy    = new RetryPolicy(1, 1),
                    Pipeline       = new TriggerPipelineReference()
                }
            };

            TriggerPipelineReference triggerPipelineReference = new TriggerPipelineReference()
            {
                PipelineReference = new PipelineReference(pipelineName),
                Parameters        = new Dictionary <string, object>()
            };

            string[] outputBlobNameList = new string[1];
            outputBlobNameList[0] = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", outputBlobName, "@{concat('output',formatDateTime(trigger().outputs.windowStartTime,'-dd-MM-yyyy-HH-mm-ss-ffff'))}");
            outputBlobNameList[0] = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", outputBlobName, "@{concat('output',formatDateTime(trigger().outputs.windowEndTime,'-dd-MM-yyyy-HH-mm-ss-ffff'))}");

            JArray outputBlobNameArray = JArray.FromObject(outputBlobNameList);

            triggerPipelineReference.Parameters.Add("OutputBlobNameList", outputBlobNameArray);

            (resource.Properties as TumblingWindowTrigger).Pipeline = triggerPipelineReference;

            return(resource);
        }