Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
84 stars 27 forks source link

[Microsoft.Automation/automationAccounts/jobSchedules]: Poor error message if resource name incorrectly formatted #1383

Open joanteixi opened 3 years ago

joanteixi commented 3 years ago

Bicep version Bicep CLI version 0.3.255

Describe the bug

I'm trying to create an automation account + runbook + schedules + link runbook and schedules. Every thing goes well but when I add automationAccounts/jobSchedules resource, I get a 404 error:

image

Here is the bicep file, that works perfect except when I add the jobSchedules resource:

https://raw.githubusercontent.com/joanteixi/az-bicep/master/start-stop-vm/automation.bicep

Thanks!

majastrz commented 3 years ago

Please fully fill out the issue template. Without additional information, we will have to close the issue.

joanteixi commented 3 years ago

Bicep version Bicep CLI version 0.3.255

Describe the bug

I'm trying to create an automation account + runbook + schedules + link runbook and schedules. Every thing goes well but when I add automationAccounts/jobSchedules resource, I get a 404 error:

image

Here is the bicep file, that works perfect except when I add the jobSchedules resource:

https://raw.githubusercontent.com/joanteixi/az-bicep/master/start-stop-vm/automation.bicep

Thanks!

miqm commented 3 years ago

Use either parent keyword, ${account.name}/ in the sub-resources name or explicitly put dependsOn.

Without them, ARM tries to deploy all resources at once - there's no logical link between account and jobs.

joanteixi commented 3 years ago

Thanks for your help, I didn't know about parent/dependsOn keyword... but it didn't work. Now I understand better the order that the ARM templates are being deployed but it's still returning a 404 error:

resource startstop0600 'Microsoft.Automation/automationAccounts/jobSchedules@2020-01-13-preview' = {
  name: 'start-0600'
  parent: automation
  dependsOn: [
    daily_6
    startstopRunbook
  ]
  properties: {
    schedule: {
      name: '${daily_6.name}'
    }
    runbook: {
      name: '${startstopRunbook.name}'
    }

    parameters: {
      'action': 'start'
      'rg': rg
      'tagname': 'start-stop'
    }
  }
}

new bicep file at https://raw.githubusercontent.com/joanteixi/az-bicep/master/start-stop-vm/automation.bicep

Thanks for your help!

miqm commented 3 years ago

The dependsOn in the startstop0600 is unnecessary since you're using references to those objects, but it should not break anything.

Could you use bicep build command (or copy it from resource group deployments section in Azure Portal) and paste the generated json?

miqm commented 3 years ago

I think I found what's wrong.

It seems like name of the jobSchedules must be a guid - you cannot put any name you want.

Following code worked for me:

resource startstop0600 'Microsoft.Automation/automationAccounts/jobSchedules@2019-06-01' = {
  name: guid('start-0600')
  parent: automation
  properties: {
    schedule: {      
      name: daily_6.name
    }
    runbook: {
      name:  startstopRunbook.name
    }
    parameters: {
      action: 'start'
      rg: rg
      tagname: 'start-stop'
    }
  }
}

This is probably something to improve in REST api specs, that name must be a guid format.

takekazuomi commented 3 years ago

It is a problem of ARM Template Runtime that the validation information of the string part is not provided in the schema. So at this point, it's not a bicep issue. Also, RP's poor error messages take my time. These are the reasons for the reduced productivity of the biceps.

I also lost time the other day due to poor RP error messages. https://github.com/Azure/bicep/pull/2206

If you know where to give feedback on ARM Template Runtime issues, please let me know.

miqm commented 3 years ago

If you know where to give feedback on ARM Template Runtime issues, please let me know.

I think this is the best place for ARM issues. I agree that it's not a bicep as a compiler issue, but it's still a bicep ecosystem one. Bicep Team is this same team that works on ARM.

As for this particular error, the 404 was not returned from ARM runtime but from the RP itself - notice that 404 is in the error body, while the error code is BadRequest - which indicates that the payload is malformed.

For type inaccuracies Bicep Teams track it under Azure/bicep#784. You can also submit issue in https://github.com/Azure/azure-rest-api-specs or via your Support Plan.

joanteixi commented 3 years ago

Hi,

Thanks for bring me the solution... it's true that a jobSchedule don't have any string name and I remove the dependsOn array from the jobScheduler.

I'm gonna a close this issue, as it has been fixed.

Thanks you very much!

tang2087 commented 1 year ago

I think I found what's wrong.

It seems like name of the jobSchedules must be a guid - you cannot put any name you want.

Following code worked for me:

resource startstop0600 'Microsoft.Automation/automationAccounts/jobSchedules@2019-06-01' = {
  name: guid('start-0600')
  parent: automation
  properties: {
    schedule: {      
      name: daily_6.name
    }
    runbook: {
      name:  startstopRunbook.name
    }
    parameters: {
      action: 'start'
      rg: rg
      tagname: 'start-stop'
    }
  }
}

This is probably something to improve in REST api specs, that name must be a guid format.

I got the same error and I think Microsoft should actually add more details about documentation for this.

kenchon commented 1 year ago

I've experienced the same error with uninformative message:

ERROR: {"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"Conflict","message":"{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The 'AzureAsyncOperationWaiting' resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"DeploymentFailed\",\r\n        \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\r\n        \"details\": [\r\n          {\r\n            \"code\": \"NotFound\",\r\n            \"message\": \"{\\r\\n  \\\"error\\\": {\\r\\n    \\\"code\\\": \\\"BadRequest\\\",\\r\\n    \\\"message\\\": \\\"\\\"\\r\\n  }\\r\\n}\"\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}"}]}}

The error was finally solved by using guid() as mentioned above.

I want maintainer to improve error message and documentation.

anthony-c-martin commented 1 year ago

Moved to Azure types repo, renamed, and re-opened. We will follow up with the provider to improve the error message.

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jaspkaur28. Please see https://aka.ms/biceptypesinfo for troubleshooting help.

Issue Details
**Bicep version** Bicep CLI version 0.3.255 **Describe the bug** I'm trying to create an automation account + runbook + schedules + link runbook and schedules. Every thing goes well but when I add automationAccounts/jobSchedules resource, I get a 404 error: ![image](https://user-images.githubusercontent.com/286098/114300037-8de52300-9abe-11eb-8318-308f7cb1ece0.png) Here is the bicep file, that works perfect except when I add the jobSchedules resource: https://raw.githubusercontent.com/joanteixi/az-bicep/master/start-stop-vm/automation.bicep Thanks!
Author: joanteixi
Assignees: -
Labels: `inaccuracy`, `RP: Microsoft.Automation`, `Service Attention`, `Automation`
Milestone: -