0

I am using Bicep to create an Automation Account, Blob storage, uploading a file to Blob, and then creating a Runbook inside my Automation Account. This works the first time, but if i update the file that goes into my blob, this isnt reflected in my runbook.

Here is a copy of my runbook deployment - is it possible the publish link URI gets cached and it doesn't 'refetch' the script content?

resource symbolicname 'Microsoft.Automation/automationAccounts/runbooks@2022-08-08' = {
  name: 'Schedule Summary Table Rebuild'
  location: automationAccount.location
  tags: _tags
  dependsOn: [deploymentScript]
  parent: automationAcc
  properties: {
    description: 'Automation to recreate summary tables.'
    logActivityTrace: 0
    logProgress: true
    logVerbose: true
    runbookType: 'PowerShell7'
    publishContentLink: {
      uri:'https://storageacc.blob.core.windows.net/data/ExecuteSQL.txt'
      version:'1.0.0.0'
    }
    
  }
  
}```
Thomas
  • 24,234
  • 6
  • 81
  • 125
Optional
  • 85
  • 7
  • You need to redeploy your run book. This is not a permanent link. The link just allow you to create a runbook from an uploaded file. If you update the file, you would need to redpleoy the runbook – Thomas Dec 03 '22 at 23:39
  • How do i do that via Bicep? – Optional Dec 03 '22 at 23:43
  • you just rerun your bicep file – Thomas Dec 03 '22 at 23:48
  • Oh i do, and thats where i noticed the script isn't updated, it doesnt seem to pull the latest from the Blob – Optional Dec 03 '22 at 23:50
  • Oh ok sorry i didn't understand your question properly. It is possible that because the url hasn't changed, the deployment is doing nothing. You can try adding a random query parameter at the end of the url to see if that work: `https://storageacc.blob.core.windows.net/data/ExecuteSQL.txt?force-update=unique-string` – Thomas Dec 04 '22 at 00:00

1 Answers1

1

When you redeploy the template, nothing has changed so I'm guessing the ARM API doesn't even try to resubmit the deployment to the resource provider.

You could add a parameter to try to force the update:

param forceUpdate string = newGuid()
...

resource symbolicname 'Microsoft.Automation/automationAccounts/runbooks@2022-08-08' = {
  name: 'Schedule Summary Table Rebuild'
  location: automationAccount.location
  tags: _tags
  dependsOn: [ deploymentScript ]
  parent: automationAcc
  properties: {
    description: 'Automation to recreate summary tables.'
    logActivityTrace: 0
    logProgress: true
    logVerbose: true
    runbookType: 'PowerShell7'
    publishContentLink: {
      uri: 'https://storageacc.blob.core.windows.net/data/ExecuteSQL.txt?forceUpdate=${forceUpdate}'
      version: '1.0.0.0'
    }
  }
}
...
Thomas
  • 24,234
  • 6
  • 81
  • 125