private async Task <SubmitJobResponse> SubmitRenderingJob(AWSCredentials credentials, RemoteCredentials config, string jobName, string bakeJobId) { var batchClient = new AmazonBatchClient(credentials); var request = new SubmitJobRequest { JobDefinition = config.RenderJobDefinitionId, JobName = jobName, JobQueue = config.RenderJobQueueId, Parameters = new Dictionary <string, string> { { "job", jobName } }, DependsOn = new List <JobDependency>() }; if (!string.IsNullOrEmpty(bakeJobId)) { request.DependsOn.Add(new JobDependency { JobId = bakeJobId, Type = ArrayJobDependency.N_TO_N }); } var response = await batchClient.SubmitJobAsync(request); return(response); }
public async Task <bool> SubmitJob(string name, string jobARN, string queueARN, Dictionary <string, string> parameters) { await amazonBatchClient.SubmitJobAsync(new SubmitJobRequest() { JobName = name, JobDefinition = jobARN, JobQueue = queueARN, Parameters = parameters }); return(true); }
private async Task <SubmitJobResponse> SubmitBakeJob(AWSCredentials credentials, RemoteCredentials config, string jobName) { var batchClient = new AmazonBatchClient(credentials); var response = await batchClient.SubmitJobAsync(new SubmitJobRequest { JobDefinition = config.BakeJobDefinitionId, JobName = jobName, JobQueue = config.BakeJobQueueId, Parameters = new Dictionary <string, string> { { "job", jobName } }, ContainerOverrides = new ContainerOverrides() {/* * ResourceRequirements = new List<ResourceRequirement> { * new ResourceRequirement() * { * Type = ResourceType.VCPU, * Value = "36" * }, * new ResourceRequirement() * { * Type = ResourceType.MEMORY, * Value = "70000" * } * },*/ Vcpus = 36, Memory = 70000 } }); return(response); }
public string Post([FromBody] Models.ModeloS3 data) { AmazonBatchClient batchClient = new AmazonBatchClient(); SubmitJobResponse submitJobResponse1 = batchClient.SubmitJobAsync(new SubmitJobRequest() { ContainerOverrides = new ContainerOverrides() //opciones de contenedor { Command = new List <string>() { data.bucket, data.key } //input del contenedor }, JobDefinition = "formacionBatch", //definicion de trabajo JobName = "trabajo-webservice", //nombre del trabajo JobQueue = "formacionBatch", //cola de trabajo }).Result; string clusterEndpoint = "docdb-2021-03-31-11-44-27.cluster-cihrsqslvehp.eu-west-1.docdb.amazonaws.com:27017"; string template = "mongodb://{0}:{1}@{2}/sampledatabase?ssl=true&replicaSet=rs0&readpreference={3}"; string username = "******"; string password = "******"; string readPreference = "secondaryPreferred"; string connectionString = String.Format(template, username, password, clusterEndpoint, readPreference); string pathToCAFile = "rdscombinedcabundle_cert_out.p7b"; // ADD CA certificate to local trust store // DO this once - Maybe when your service starts X509Store localTrustStore = new X509Store(StoreName.Root); X509Certificate2Collection certificateCollection = new X509Certificate2Collection(); certificateCollection.Import(pathToCAFile); try { localTrustStore.Open(OpenFlags.ReadWrite); localTrustStore.AddRange(certificateCollection); } catch (Exception ex) { Console.WriteLine("Root certificate import failed: " + ex.Message); throw; } finally { localTrustStore.Close(); } var settings = MongoClientSettings.FromUrl(new MongoUrl(connectionString)); var client = new MongoClient(settings); var database = client.GetDatabase("sample_database"); var collection = database.GetCollection <BsonDocument>("tracking"); collection.InsertOne(new BsonDocument { { "ip", HttpContext.Connection.RemoteIpAddress.ToString() }, { "fecha", DateTime.Now }, { "bucket", data.bucket }, { "key", data.key }, }); return("Trabajo enviado"); }
static void Main(string[] args) { string accessKey = ""; string secretKey = ""; Amazon.RegionEndpoint region = Amazon.RegionEndpoint.EUWest1; string strIdCuenta = ""; //Ejecucion de tarea en Fargate AmazonECSClient ECSClient = new AmazonECSClient(accessKey, secretKey, region); RunTaskResponse runTaskResponse = ECSClient.RunTaskAsync(new RunTaskRequest() { Cluster = "practica1", //nombre del cluster Count = 1, //número de tareas LaunchType = Amazon.ECS.LaunchType.FARGATE, //tipo de ejecucion NetworkConfiguration = new Amazon.ECS.Model.NetworkConfiguration() //configuracion de red { AwsvpcConfiguration = new Amazon.ECS.Model.AwsVpcConfiguration() //tipo de red awsvpc, la usada por Fargate { Subnets = new List <string>() { "subnet-831004e5" }, //subredes AssignPublicIp = Amazon.ECS.AssignPublicIp.ENABLED //asignar IP púlica } }, Overrides = new TaskOverride() //configuracion de contenedores { ContainerOverrides = new List <ContainerOverride>() //lista de contenedores a configurar { new ContainerOverride() //opciones del contenedor { Name = "FormacionFargateTask", //nombre del contenedor Command = new List <string>() { "formacion-batch-sieca", "mifichero" } //input del contenedor } } }, TaskDefinition = "FormacionFargateTask" //tarea a ejecutar }).Result; //Ejecucion de trabajo en Batch AmazonBatchClient batchClient = new AmazonBatchClient(accessKey, secretKey, region); SubmitJobResponse submitJobResponse = batchClient.SubmitJobAsync(new SubmitJobRequest() { ContainerOverrides = new ContainerOverrides() //opciones de contenedor { Command = new List <string>() { "formacion-batch-sieca", "mifichero" } //input del contenedor }, JobDefinition = "formacionBatch", //definicion de trabajo JobName = "mi-trabajo", //nombre del trabajo JobQueue = "formacionBatch", //cola de trabajo }).Result; }