title: Why does my Azure Powershell runbook get suspended when executed as a schedule and how do I prevent retry?
body: <p>I am very new to Azure Automation Runbooks but I have been authoring a powershell script that performs a backup of a SQL Azure database into a bacpac file to a blob storage container which then get's uploaded to Google Drive for an 'offsite' backup. I have implemented this functionality as 1 month ago Microsoft kindly terminated my Azure Subscription accidentally and I could not access my database backups as they were part of the account. </p>
  
  <p>Having written the script, I successfully used the test feature which performed the task admirably. Subsequently I configured a daily schedule that would perform the backup on a nightly basis. What I found the next morning is that the backup aspect worked successfully and the file was indeed posted to Google Drive, but there were three copies of it. The Azure Portal marks the job as 'suspended' and I'm told that the job failed and was retried 3 times. </p>
  
  <p>I've read into the Invoke-WebRequest and have suspicions that it is timing out, even though the documentation indicates that the default behavior is to not time out. Other suggests are to use 'inline' scripting but I thought this only applied to workflow runbooks, rather than my specific script runbook.</p>
  
  <p>The command that I believe fails is:</p>
  
  <pre><code>Write-Verbose "Uploading database to google drive using a timeout of 600 seconds..."
  $uploadrequest = Invoke-WebRequest -method Post -uri $GUploadURI -body $GUploadBody -Headers $Guploadheaders -usebasicparsing -TimeoutSec 600
  Write-Verbose "Uploaded database to google drive." 
  </code></pre>
  
  <p>But I am not notified of an error. The log shows that the runbook writes the verbose line 'Uploading database to google drive..' and after that seems to go back to the beginning and repeats itself a further 2 times.</p>
  
  <p>The timeoutsec was introduced as a trial to see if I could override the timeout feature (although I'm guessing this is the problem). The log does not show the subsequent verbose message 'uploaded database to google drive' so clearly the WebRequest is failing for some reason. </p>
  
  <p>As further information I'm forced to read the blob content of the database into a local temp file which I then have to read into memory in order to post to Google as a multi-part message. The database is 16Mbytes in size at the moment. This could be the problem as I'm told that runbooks are quite stringent with memory allocation. </p>
  
  <pre><code>Write-Verbose "Creating temporary file for blob content..."
  $file = New-TemporaryFile
  Write-Verbose "Downloading blob content to temporary file..." 
  $blob = Get-AzureStorageBlobContent -Container $container -Blob $blob -Context $storageContext -Destination $file -Force
  Write-Verbose "Extracting file content as RAW"
  $togoogle = Get-Content $file -Raw -ErrorAction:SilentlyContinue
  </code></pre>
  
  <p>I would really appreciate some advice on what to do here and as a bonus how to prevent the re-try also as I can see how to configure that in the powershell runbook's either.</p>