How to deploy Arc Extension Microsoft.Azure.Automation.HybridWorker via REST API

Peter Smit 1 Reputation point
2022-02-02T15:50:27.613+00:00

Hi, I am trying to deploy an Microsoft.Azure.Automation.HybridWorker via powershell and REST API but it fails with the following error:

{"Message":"Specified machineId is not associated with automation account.

This is the method I am used:

$PutHybridRunbookWorkerUri = "https://management.azure.com/subscriptions/$($SubscriptionId)/resourceGroups/$($resourceGroupName)/providers/Microsoft.HybridCompute/machines/$($machineName)/extensions/HybridWorkerExtension?api-version=2021-05-20"
$RequestBodyHybridRunbookWorker = @{
"location" = $($location)
"properties" = @{
"publisher" = "Microsoft.Azure.Automation.HybridWorker"
"type" = "HybridWorkerForWindows"
"typeHandlerVersion" = "0.1.0.18"
"autoUpgradeMinorVersion" = $false
"enableAutomaticUpgrade" = $false
"settings" = @{
"AutomationAccountURL" = $AutomationAccountUrl
}
"protectedSettings" = @{
"primaryaccesskey" = $AutomationAccountKey
}
}
} | ConvertTo-Json -depth 3
Invoke-RestMethod -Headers @{Authorization = "Bearer $token" } -Body $RequestBodyHybridRunbookWorker -Uri $PutHybridRunbookWorkerUri -Method put -ContentType "application/json"

Any ideas?

Kind regards,

Peter Smit

Azure Arc
Azure Arc

A Microsoft cloud service that enables deployment of Azure services across hybrid and multicloud environments.

Azure Automation
Azure Automation

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

Windows for business | Windows Server | User experience | PowerShell

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.