Azure Bicep & Microsoft.DevTestLab/schedules cannot get targetResourceId #5086
-
Hi all, I am trying to implement simple thing using Bicep, but somehow cannot get through and I am pretty sure it'll be something stupid. Using copy loop while creating shutdown schedule, to create a schedule for VMs mentioned in parameter file, but getting 'Code:InvalidScheduleId'. I guess the issue is somewhere around target specification (targetResourceId), but not sure what could be wrong there. Any ideas? targetResourceId: '/subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Compute/virtualMachines/${item.ServerName}-${item.ServerSite}' Bicep & template: Error: ###################################################### param Par_Location string = resourceGroup().location resource ShutdownVMs 'Microsoft.DevTestLab/schedules@2018-09-15' = [for item in Par_Servers: { ###################################################### Deploying Azure Resource into: RG-Showcase DeploymentName : DeployShutdownSchedule Outputs : |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @Jetelaczek In this case there is a very specific naming standard required, which is: So just replace whatever you used to name your virtualMachine with In the case of the sample: // name of vm
name: '${Deployment}-vm${vm.Name}'
// name of schedule
name: 'shutdown-computevm-${Deployment}-vm${vm.Name}' so computername is: |
Beta Was this translation helpful? Give feedback.
Hi @Jetelaczek
In this case there is a very specific naming standard required, which is:
shutdown-computevm-${computerName}
So just replace whatever you used to name your virtualMachine with
computerName
above.Sample here:
https://github.com/brwilkinson/AzureDeploymentFramework/blob/f79d488fb6fd6191629f65d46b98297979464200/ADF/bicep/VM.bicep#L326
In the case of the sample:
so computername is:
${Deployment}-vm${vm.Name}