Skip to content

azurermBatchJob

Manages a Batch Job.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.provider.AzurermProvider(this, "azurerm", {
  features: [{}],
});
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "west europe",
    name: "example-rg",
  }
);
const azurermBatchAccountExample = new azurerm.batchAccount.BatchAccount(
  this,
  "example_2",
  {
    location: azurermResourceGroupExample.location,
    name: "exampleaccount",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBatchAccountExample.overrideLogicalId("example");
const azurermBatchPoolExample = new azurerm.batchPool.BatchPool(
  this,
  "example_3",
  {
    account_name: azurermBatchAccountExample.name,
    fixed_scale: [
      {
        target_dedicated_nodes: 1,
      },
    ],
    name: "examplepool",
    node_agent_sku_id: "batch.node.ubuntu 16.04",
    resource_group_name: azurermResourceGroupExample.name,
    storage_image_reference: [
      {
        offer: "UbuntuServer",
        publisher: "Canonical",
        sku: "16.04.0-LTS",
        version: "latest",
      },
    ],
    vm_size: "Standard_A1",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBatchPoolExample.overrideLogicalId("example");
const azurermBatchJobExample = new azurerm.batchJob.BatchJob(
  this,
  "example_4",
  {
    batch_pool_id: azurermBatchPoolExample.id,
    name: "examplejob",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBatchJobExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • batchPoolId - (Required) The ID of the Batch Pool. Changing this forces a new Batch Job to be created.

  • name - (Required) The name which should be used for this Batch Job. Changing this forces a new Batch Job to be created.


  • commonEnvironmentProperties - (Optional) Specifies a map of common environment settings applied to this Batch Job. Changing this forces a new Batch Job to be created.

  • displayName - (Optional) The display name of this Batch Job. Changing this forces a new Batch Job to be created.

  • taskRetryMaximum - (Optional) The number of retries to each Batch Task belongs to this Batch Job. If this is set to 0, the Batch service does not retry Tasks. If this is set to 1, the Batch service retries Batch Tasks without limit. Default value is 0.

  • priority - (Optional) The priority of this Batch Job, possible values can range from -1000 (lowest) to 1000 (highest). Defaults to 0.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Batch Job.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 5 minutes) Used when creating the Batch Job.
  • read - (Defaults to 5 minutes) Used when retrieving the Batch Job.
  • update - (Defaults to 5 minutes) Used when updating the Batch Job.
  • delete - (Defaults to 5 minutes) Used when deleting the Batch Job.

Import

Batch Jobs can be imported using the resourceId, e.g.

terraform import azurerm_batch_job.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Batch/batchAccounts/account1/pools/pool1/jobs/job1