title: Azure VM Scale Set: is it possible to pass bootstrap script/settings without downloading them from URL?
body: <p>I can see that with Custom Script Extension it is possible to bootstrap new VMs (in Scale Set). To access a script it needs azure storage URI and credentials. This approach doesn't work for me because (internal policies) it's not allowed to pass storage credentials.</p>
  
  <p>My VMSS has assigned service identity, the latter is registered with KeyVault. So, it is quite straightforward to get credentials directly on a box. But for this I need at least small bootstrap script =)</p>
  
  <p>I found one hacky way how to achieve this through Custom Script Extension:</p>
  
  <pre><code>$bootstrapScriptPath = Join-Path -Path $PSScriptRoot -ChildPath "bootstrap.ps1"
  $bootstrapScriptBlock = get-command $bootstrapScriptPath | Select -ExpandProperty ScriptBlock
  $installScriptBase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($bootstrapScriptBlock.ToString()))
  
  "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -EncodedCommand ', parameters('installScriptBase64'))]"
  </code></pre>
  
  <p>But I wonder whether there are better solutions.</p>
  
  <p>Essentially I need something which Cloud Service provides - ability to upload payload and config settings. </p>
  
  <p><strong>SOLUTION</strong> </p>
  
  <p>(note, this is for Windows VM. For Linux VM there is an easier way - thanks to @sendmarsh)</p>
  
  <p>Please see below for actual implementation (note, I marked as answer a post from @4c74356b41 who suggested this idea).</p>