bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Can't deploy hybridRunbookWorkerGroups without error

Open jbla9028 opened this issue 5 years ago • 10 comments

Bicep version run bicep --version via the Bicep CLI, az bicep version via the AZ CLI or via VS code by navigating to the extensions tab and searching for Bicep

Bicep CLI version 0.4.1008 (223b8d227a)

Describe the bug I am trying to deploy a hybrid worker group, hybrid worker, and then deploy the hybrid extension to a basic windows VM. When I go to run this code, The group successfully creates but throws an error.

resource hybrid_worker_group 'Microsoft.Automation/automationAccounts/hybridRunbookWorkerGroups@2021-06-22' = {
  name: 'HybridGroup1'
  parent: automation_test_acct
  dependsOn:[automation_credential
  ]
}

Error message

{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"InternalServerError","message":"{\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The response for resource had empty or invalid content.\"\r\n  }\r\n}"}]}}

Raw error

{
  "code": "DeploymentFailed",
  "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
  "details": [
    {
      "code": "ResourceDeploymentFailure",
      "message": "The response for resource had empty or invalid content."
    }
  ]
}

So looking at the provider documentation here - https://docs.microsoft.com/en-us/azure/templates/microsoft.automation/2021-06-22/automationaccounts/hybridrunbookworkergroups?tabs=bicep#runascredentialassociationproperty

I need to reference a credential block. I do not need to do this in the portal though and it can be blank. I have tried just including a blank credential block, omitting the block and for the heck of it, deploying a credential and then referencing the credential in multiple ways (static name, referencing credential_test.name, credential_test.property.description) and then I get this error

resource automation_credential 'Microsoft.Automation/automationAccounts/credentials@2020-01-13-preview' = {
  name: 'unused'
  parent: automation_test_acct
  properties: {
    description: 'unused'
    password: 'username'
    userName: 'password123'
  }
}

output output2 string = automation_credential.name


resource hybrid_worker_group 'Microsoft.Automation/automationAccounts/hybridRunbookWorkerGroups@2021-06-22' = {
  name: 'HybridGroup1'
  parent: automation_test_acct
  credential: {
    name: automation_credential.properties.description
  }
  dependsOn:[automation_credential
  ]
}
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"InternalServerError","message":"{\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The response for resource had empty or invalid content.\"\r\n  }\r\n}"}]}}

Additional context I know this feature is in preview but trying to see if this is a problem with my bicep code or from what I can tell appears to be potentially a bug. any help is appreciated!

jbla9028 avatar Nov 26 '21 14:11 jbla9028

I also want to mention this code actually deploys the worker group but just throws the error mentioned above. It should succeed and move on :)

resource hybrid_worker_group 'Microsoft.Automation/automationAccounts/hybridRunbookWorkerGroups@2021-06-22' = { name: 'HybridGroup1' parent: automation_test_acct dependsOn:[automation_credential ] }

jbla9028 avatar Nov 26 '21 14:11 jbla9028

Some more info I've found.

The example ARM template found here. https://docs.microsoft.com/en-us/azure/automation/extension-based-hybrid-runbook-worker-install

if you load the code into VS code, the ARM template helper is complaining that the type field is wrong

`

      "name": "[concat(parameters('workerGroupName'),'/',guid('AzureAutomationJobName', variables('UniqueStringBasedOnTimeStamp')))]",
      "type": "hybridRunbookWorkerGroups/hybridRunbookWorkers",   //This line here!!!
      "apiVersion": "2021-06-22",
      "dependsOn": [
        "[resourceId('Microsoft.Automation/automationAccounts', parameters('automationAccount'))]",
        "[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]"
      ],
      "properties": {
        "vmResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]"
      }
    }
  ]
},

`

Value must be one of the following values: "hybridRunbookWorkers"arm-template (schema) type Resource type Type: string

If I try to update this and run it as an arm template it fails.

jbla9028 avatar Nov 26 '21 15:11 jbla9028

An InternalServerError is a service-side bug and either means the resource provider service is down or in some bad state or there is a bug in the error handling logic. Are you able to open a support case to involve the AutomationAccount team?

The error you are getting on the ARM template you found is a result of a missing schema for that type and is not likely the cause of your issue.

alex-frankel avatar Nov 26 '21 17:11 alex-frankel

Thank you. I have a support ticket open with Microsoft, I've sent a bunch of this detail to support but don't think the support engineer understands it as a provider issue as he doesn't know ARM templates/Bicep and is just pointing me at the FAQ and troubleshooting section on the automation account. I will escalate up when I get a response from my latest email. Thank you.

jbla9028 avatar Nov 26 '21 17:11 jbla9028

Awesome - please keep us updated on the resolution.

alex-frankel avatar Nov 29 '21 17:11 alex-frankel

I have the exact same issue. The group is successfully created but throws the same error. note: this happens on most, but not every deployment.

Virgil-Bulens avatar Dec 16 '21 10:12 Virgil-Bulens

The ms support engineer hasn't been very helpful with this. I basically have been waiting for almost 2 weeks for him to run the same steps in the ms documentation and confirm I'm not doing something wrong and alert the team responsible for the azure automation account API or confirm the issue is with bicep vs just ARM templates.

jbla9028 avatar Dec 16 '21 11:12 jbla9028

I have a similar issue with this extension in Terraform where the terraform provider for the automation account outputs the url for the autoMation account but this extension when you try to install it says that the url sent was not formatted correctly.

I was able to work around this by the way by running a custom script extension to run the powershell commands to register the server to the automation account.

jbla9028 avatar Dec 16 '21 11:12 jbla9028

I was found on official site following: Create hybrid worker group

You can create a Hybrid Worker Group via the Azure portal. Currently, creating through the Azure Resource Manager (ARM) template is not supported.

So in reality creating Hybrid Worker Group by arm template works not as expected - group was created but with message: Status Message: The response for resource had empty or invalid content.

smahnovsky avatar Feb 16 '22 12:02 smahnovsky

I was going to add that I too an having the same issue, but if it's not supported then I guess we can't complain :-)

Kind of funny to think you can't fully automate and automation account ;-)

ericcsinger avatar Feb 22 '22 22:02 ericcsinger