Microsoft.Automation automationAccounts/sourceControls/sourceControlSyncJobs

Bicep resource definition

The automationAccounts/sourceControls/sourceControlSyncJobs resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs@2024-10-23' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    commitId: 'string'
  }
}

Property Values

Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs

Name Description Value
name The resource name string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ (required)
parent In Bicep, you can specify the parent resource for a child resource. You only need to add this property when the child resource is declared outside of the parent resource.

For more information, see Child resource outside parent resource.
Symbolic name for resource of type: automationAccounts/sourceControls
properties The properties of the source control sync job. SourceControlSyncJobCreatePropertiesOrSourceControlSyncJobByIdProperties (required)

SourceControlSyncJobCreatePropertiesOrSourceControlSyncJobByIdProperties

Name Description Value
commitId The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. string (required)

ARM template resource definition

The automationAccounts/sourceControls/sourceControlSyncJobs resource type can be deployed with operations that target:

Usage Examples

Resource format

To create a Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs resource, add the following JSON to your template.

{
  "type": "Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs",
  "apiVersion": "2024-10-23",
  "name": "string",
  "properties": {
    "commitId": "string"
  }
}

Property Values

Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs

Name Description Value
apiVersion The api version '2024-10-23'
name The resource name string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ (required)
properties The properties of the source control sync job. SourceControlSyncJobCreatePropertiesOrSourceControlSyncJobByIdProperties (required)
type The resource type 'Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs'

SourceControlSyncJobCreatePropertiesOrSourceControlSyncJobByIdProperties

Name Description Value
commitId The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. string (required)

Terraform (AzAPI provider) resource definition

The automationAccounts/sourceControls/sourceControlSyncJobs resource type can be deployed with operations that target:

  • Resource groups For a list of changed properties in each API version, see change log.

Usage Examples

Terraform Samples

A basic example of deploying Automation Accounts Source Control Sync Jobs.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

variable "pat" {
  type        = string
  sensitive   = true
  description = "GitHub Personal Access Token"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "automationAccount" {
  type      = "Microsoft.Automation/automationAccounts@2023-11-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  identity {
    type         = "SystemAssigned"
    identity_ids = []
  }

  body = {
    properties = {
      encryption = {
        keySource = "Microsoft.Automation"
      }
      publicNetworkAccess = true
      sku = {
        name = "Basic"
      }
    }
  }
}

resource "azapi_resource" "sourceControl" {
  type      = "Microsoft.Automation/automationAccounts/sourceControls@2023-11-01"
  name      = var.resource_name
  parent_id = azapi_resource.automationAccount.id

  body = {
    properties = {
      repoUrl        = "https://github.com/Azure-Samples/acr-build-helloworld-node.git"
      branch         = "master"
      sourceType     = "GitHub"
      folderPath     = "/"
      autoSync       = false
      publishRunbook = false

      securityToken = {
        tokenType   = "PersonalAccessToken"
        accessToken = var.pat
      }
    }
  }
}

data "azapi_resource_list" "roleDefinitions" {
  type      = "Microsoft.Authorization/roleDefinitions@2022-04-01"
  parent_id = azapi_resource.automationAccount.id
  response_export_values = {
    contributorRoleDefinitionId = "value[?properties.roleName == 'Contributor'].id | [0]"
  }
}

resource "azapi_resource" "roleAssignment" {
  type      = "Microsoft.Authorization/roleAssignments@2022-04-01"
  parent_id = azapi_resource.automationAccount.id
  name      = uuid()
  body = {
    properties = {
      principalId      = azapi_resource.automationAccount.identity[0].principal_id
      roleDefinitionId = data.azapi_resource_list.roleDefinitions.output.contributorRoleDefinitionId
    }
  }
  lifecycle {
    ignore_changes = [name]
  }
}


# use azapi_resource_action to create a sourceControlSyncJob because the API doesn't support DELETE
resource "azapi_resource_action" "sourceControlSyncJob" {
  type        = "Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs@2023-11-01"
  resource_id = provider::azapi::build_resource_id(azapi_resource.sourceControl.id, "Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs", uuid())
  method      = "PUT"

  body = {
    properties = {
      commitId = ""
    }
  }
  depends_on = [azapi_resource.roleAssignment]
  lifecycle {
    ignore_changes = [resource_id]
  }
}

Resource format

To create a Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs@2024-10-23"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      commitId = "string"
    }
  }
}

Property Values

Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs

Name Description Value
name The resource name string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ (required)
parent_id The ID of the resource that is the parent for this resource. ID for resource of type: automationAccounts/sourceControls
properties The properties of the source control sync job. SourceControlSyncJobCreatePropertiesOrSourceControlSyncJobByIdProperties (required)
type The resource type "Microsoft.Automation/automationAccounts/sourceControls/sourceControlSyncJobs@2024-10-23"

SourceControlSyncJobCreatePropertiesOrSourceControlSyncJobByIdProperties

Name Description Value
commitId The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. string (required)