Azure Automation Source Control is consistently failing to import certain runbooks

Andrew Holland 40 Reputation points
2026-07-01T14:41:38.2633333+00:00

Azure Automation Source Control is consistently failing to import certain PowerShell runbooks from GitHub.

If the runbooks are deleted, it can recreate them in 5.1 runtime w/o issues. However, it fails to update them if they already exist in runtime 7.2, which is what they need. We have other 7.2 runtime runbooks that are being updated by Source Control without issues. Recreating the Source Control connection did not help with the issue. Here are the full logs from a full sync with sensitive information substituted by AI:

User's image

Output

========================================================================================================
Azure Automation Source Control Version 1.0
Supported runbooks to sync: PowerShell Workflow, PowerShell Scripts, DSC Configurations, Graphical, and Python 2.
Setting AzureEnvironment.
Source control information for syncing:
[RepoUrl = https://github.com/ExampleOrg/ExampleRepo.git] [Branch  = main] [FolderPath = /Runbooks]
Verifying url: https://github.com/ExampleOrg/ExampleRepo.git
Connecting to GitHub...
Runbook runbook1 will created with type  PowerShell
Runbook runbook2 will created with type  PowerShell
Runbook runbook3 will created with type  PowerShell
Runbook file100 will created with type  PowerShell
Runbook runbook4 will created with type  PowerShell
Runbook runbook5 will created with type  PowerShell
Runbook runbook6 will created with type  PowerShell
Runbook file101 will created with type  PowerShell
Runbook runbook7 will created with type  PowerShell
Source Control Sync Summary:
101 files synced:
 - File1.ps1
 - File2.ps1
 - File3.ps1
 - File4.ps1
 - File5.ps1
 - File6.ps1
 - File7.ps1
 - File8.ps1
 - File9.ps1
 - File10.ps1
 - File11.ps1
 - File12.ps1
 - File13.ps1
 - File14.ps1
 - File15.ps1
 - File16.ps1
 - File17.ps1
 - File18.ps1
 - File19.ps1
 - File20.ps1
 - File21.ps1
 - File22.ps1
 - File23.ps1
 - File24.ps1
 - File25.ps1
 - File26.ps1
 - File27.ps1
 - File28.ps1
 - File29.ps1
 - File30.ps1
 - File31.ps1
 - File32.ps1
 - File33.ps1
 - File34.ps1
 - File35.ps1
 - File36.ps1
 - File37.ps1
 - File38.py
 - File39.ps1
 - File40.ps1
 - File41.ps1
 - File42.ps1
 - File43.ps1
 - File44.ps1
 - File45.py
 - File46.ps1
 - File47.ps1
 - File48.ps1
 - File49.ps1
 - File50.ps1
 - File51.ps1
 - File52.ps1
 - File53.ps1
 - File54.ps1
 - File55.ps1
 - File56.ps1
 - File57.ps1
 - File58.ps1
 - File59.ps1
 - File60.ps1
 - File61.ps1
 - File62.ps1
 - File63.ps1
 - File64.ps1
 - File65.ps1
 - File66.ps1
 - File67.ps1
 - File68.ps1
 - File69.ps1
 - File70.ps1
 - File71.ps1
 - File72.ps1
 - File73.ps1
 - File74.ps1
 - File75.ps1
 - File76.ps1
 - File77.ps1
 - File78.ps1
 - File79.ps1
 - File80.ps1
 - File81.ps1
 - File82.ps1
 - File83.ps1
 - File84.ps1
 - File85.ps1
 - File86.ps1
 - File87.ps1
 - File88.ps1
 - File89.ps1
 - File90.ps1
 - File91.ps1
 - File92.ps1
 - File93.ps1
 - File94.ps1
 - File95.ps1
 - File96.ps1
 - File97.ps1
 - File98.ps1
 - File99.ps1
 - File100.ps1
 - File101.ps1
Failed to import runbook:
 - Runbook1.ps1
 - Runbook2.ps1
 - Runbook3.ps1
 - Runbook4.ps1
 - Runbook5.ps1
 - Runbook6.ps1
 - Runbook7.ps1

Error [16]

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook1.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook2.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook3.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook4.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook5.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook6.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to create runbook as draft for automation account with Bad Request(400)

Failed to import runbook 'Runbook7.ps1'.
Exception: Failed to create runbook as draft for automation account with Bad Request(400)

Failed to sync. 
Failed to import runbook:
 - Runbook1.ps1
 - Runbook2.ps1
 - Runbook3.ps1
 - Runbook4.ps1
 - Runbook5.ps1
 - Runbook6.ps1
 - Runbook7.ps1

There were errors while syncing the user runbooks. Please see error streams for more information.

All Logs

========================================================================================================
Azure Automation Source Control Version 1.0
Supported runbooks to sync: PowerShell Workflow, PowerShell Scripts, DSC Configurations, Graphical, and Python 2.
Setting AzureEnvironment.
GET http://localhost/metadata/identity/oauth2/token?resource=https://management.azure.com with 0-byte payload
received -1-byte response of content type application/json; charset=utf-8
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ExampleResourceGroup/providers/Microsoft.Automation/automationAccounts/ExampleAutomationAccount/sourceControls/github/listKeys?api-version=2017-05-15-preview with 0-byte payload
received 80-byte response of content type application/json; charset=utf-8
GET http://localhost/metadata/identity/oauth2/token?resource=https://management.azure.com with 0-byte payload
received -1-byte response of content type application/json; charset=utf-8
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ExampleResourceGroup/providers/Microsoft.Automation/automationAccounts/ExampleAutomationAccount/sourceControls/github?api-version=2017-05-15-preview with 0-byte payload
received 520-byte response of content type application/json; charset=utf-8
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ExampleResourceGroup/providers/Microsoft.Automation/automationAccounts/ExampleAutomationAccount/sourceControls/github/listKeys?api-version=2017-05-15-preview with 0-byte payload
received 80-byte response of content type application/json; charset=utf-8
Source control information for syncing:
[RepoUrl = https://github.com/ExampleOrg/ExampleRepo.git] [Branch  = main] [FolderPath = /Runbooks]
Verifying url: https://github.com/ExampleOrg/ExampleRepo.git
Connecting to GitHub...
POST https://api.github.com/graphql with -1-byte payload
received 39-byte response of content type application/json; charset=utf-8
POST https://api.github.com/graphql with -1-byte payload
received 6163-byte response of content type application/json; charset=utf-8
POST https://api.github.com/graphql with -1-byte payload
received -1-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File1.ps1?ref=main with 0-byte payload
received 52971-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File2.ps1?ref=main with 0-byte payload
received 5015-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File3.ps1?ref=main with 0-byte payload
received 33835-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File4.ps1?ref=main with 0-byte payload
received 82576-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File5.ps1?ref=main with 0-byte payload
received 12615-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File6.ps1?ref=main with 0-byte payload
received 22567-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File7.ps1?ref=main with 0-byte payload
received 10799-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File8.ps1?ref=main with 0-byte payload
received 10364-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File9.ps1?ref=main with 0-byte payload
received 8697-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File10.ps1?ref=main with 0-byte payload
received 11426-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File11.ps1?ref=main with 0-byte payload
received 4250-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File12.ps1?ref=main with 0-byte payload
received 6130-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File13.ps1?ref=main with 0-byte payload
received 8593-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File14.ps1?ref=main with 0-byte payload
received 6691-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File15.ps1?ref=main with 0-byte payload
received 50259-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File16.ps1?ref=main with 0-byte payload
received 29059-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File17.ps1?ref=main with 0-byte payload
received 55321-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File18.ps1?ref=main with 0-byte payload
received 27186-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File19.ps1?ref=main with 0-byte payload
received 26491-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File20.ps1?ref=main with 0-byte payload
received 59064-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File21.ps1?ref=main with 0-byte payload
received 22404-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File22.ps1?ref=main with 0-byte payload
received 3153-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File23.ps1?ref=main with 0-byte payload
received 3914-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File24.ps1?ref=main with 0-byte payload
received 3743-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File25.ps1?ref=main with 0-byte payload
received 7137-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File26.ps1?ref=main with 0-byte payload
received 18032-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File27.ps1?ref=main with 0-byte payload
received 15987-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File28.ps1?ref=main with 0-byte payload
received 5910-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File29.ps1?ref=main with 0-byte payload
received 103514-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File30.ps1?ref=main with 0-byte payload
received 15705-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File31.ps1?ref=main with 0-byte payload
received 12292-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File32.ps1?ref=main with 0-byte payload
received 23638-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File33.ps1?ref=main with 0-byte payload
received 17494-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File34.ps1?ref=main with 0-byte payload
received 9019-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File35.ps1?ref=main with 0-byte payload
received 15929-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File36.ps1?ref=main with 0-byte payload
received 18331-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File37.ps1?ref=main with 0-byte payload
received 26868-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File38.py?ref=main with 0-byte payload
received 8683-byte response of content type application/json; charset=utf-8
GET https://api.github.com/repos/ExampleOrg/ExampleRepo/contents/Runbooks/File39.ps1?ref=main with 0-byte payload
received 5277-byte response of content type application/json; charset=utf-8
Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

0 comments No comments

Answer accepted by question author

Jerald Felix 17,640 Reputation points Volunteer Moderator
2026-07-01T15:38:19.1166667+00:00

Hello Andrew Holland,

Greetings! Thanks for raising this question in the Q&A forum.

The root cause here is a known platform limitation rather than a misconfiguration on your side. Azure Automation Source Control integration was built around PowerShell 5.1 and Python 2.7/3.8, and it does not officially support PowerShell 7.2 runbooks. When source control creates a brand new runbook that doesn't exist yet, it silently creates it as a PowerShell 5.1 runbook, which is exactly why deleting a runbook lets the sync succeed without errors. But when a runbook with that same name already exists and is linked to the 7.2 runtime, the sync engine tries to push an updated draft that conflicts with the runbook's assigned runtime type, and the Automation API rejects it with Bad Request(400). This also explains why recreating the source control connection didn't help, since the connection itself isn't the problem.

Here is how to work around this.

Confirm the runtime mismatch. In the Azure portal, open your Automation account, go to Runbooks, and check the Runtime version column for Runbook1 through Runbook7. If they show 7.2 while the successfully synced runbooks show 5.1, that confirms this is the same limitation described in Microsoft's own troubleshooting docs.

Move these specific runbooks out of Source Control sync. Since Source Control only reliably manages PowerShell 5.1 content, the safest long-term fix is to stop relying on the built-in Git sync for any runbook that must run on 7.2, and instead deploy those through your own CI/CD pipeline that calls the Automation API directly and can target the 7.2 runtime explicitly.

Deploy the 7.2 runbooks via Az PowerShell in a pipeline instead. In an Azure DevOps pipeline or GitHub Actions workflow, use Import-AzAutomationRunbook with -Force so it updates existing runbooks instead of failing, and explicitly set the type to PowerShell7:

Import-AzAutomationRunbook `
  -Path ".\Runbook1.ps1" `
  -Name "Runbook1" `
  -ResourceGroupName "ExampleResourceGroup" `
  -AutomationAccountName "ExampleAutomationAccount" `
  -Type PowerShell7 `
  -Force

Publish-AzAutomationRunbook `
  -Name "Runbook1" `
  -ResourceGroupName "ExampleResourceGroup" `
  -AutomationAccountName "ExampleAutomationAccount"
  1. If you're using the newer Runtime Environment experience instead of the legacy 7.2 type, link the runbook explicitly to the correct runtime environment via REST after import, since Source Control has no awareness of Runtime Environments at all:
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/ExampleResourceGroup/providers/Microsoft.Automation/automationAccounts/ExampleAutomationAccount/runbooks/Runbook1?api-version=2024-10-23
{
  "properties": {
    "runtimeEnvironment": "YourPowerShell72RuntimeEnvironmentName",
    "runbookType": "PowerShell"
  }
}

Keep Source Control scoped to only the runbooks that are actually 5.1 compatible. If some of these seven runbooks don't strictly need 7.2 features, moving them back to 5.1 will let Source Control manage them without any special casing, and you only need the pipeline-based workaround for the ones that truly require 7.2.

Split your repo folder structure if practical, so 5.1 runbooks stay in the folder path your existing Source Control connection watches, and 7.2 runbooks live in a separate folder that only your pipeline touches. This avoids any ambiguity about which mechanism owns which files.

This is a documented gap rather than something Azure Support can toggle on for your account, so unless Microsoft ships explicit 7.2 support for Source Control, the pipeline-based deployment above is the supported path forward for those seven runbooks.

If this answer helps you kindly accept the answer which will help others who have similar questions.

Best Regards,

Jerald Felix.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.