Reputation: 125
I am looking to copy a file from my storage account to a VM that is being created using an ARM template?
I have already created the storage account and added the files to the storage account. I am busy creating the template but don't see any option to copy the files from the storage account to the OSDisk that gets created when creating the VirtualMachine.
Update I feel I should give some background of what I want to achieve:
So based on this I need to somehow copy the files from storage to the VM before the azure docker extension executes.
Upvotes: 3
Views: 4091
Reputation: 8737
If you want to do it with DSC, here's a sample: https://github.com/bmoore-msft/AzureRM-Samples/tree/master/VMDSCInstallFile. Ed's answer might be a simpler approach though. The key here is getting the credentials to the VM to be able to pull from storage. That means whether you're using DSC or a custom script, you need to get the location/uri and a sasToken to the script (unless the files are unsecured). The DSC sample above will give you a way to pass the uri/token that will work in either workflow. Look at the PS script in the root to see how the uri & token are created and passed to the template deployment.
Upvotes: 1
Reputation: 1279
One way of achieving this would be to use a Custom script extension, which is added to your VM. It allows you to run a powershell script at the time of deployment that runs on the VM. In the JSON outline window in Visual Studio, click add resource
Then add a custom script extension and link it to the VM
This will add a blank powershell script to the newly created custom script folder in your project. Here you can put the script to download the file from blob. Like this.
Upvotes: 4