Azure – How to copy a custom package from Azure Storage to install on a machine with DSC

azuredsc

I'm currently using Azure Resource Manager to create virtual machines with DSC to configure basic state and install IIS. I already have a build environment that dumps websites as .zip files to Azure Storage. But, I can't figure out how to make DSC reach out to Azure Storage to download the .zip and place it in wwwroot.

Ultimately, I want to run AzureRM so that it creates a new VM, runs DSC so that when it's finished my app is on the machine and running.

Best Answer

How we do it is to use the xRemoteFile DSC resource, from the xPsDesiredState resource kit. This lets you specify a remote URL (such as Azure storage) and downloads the file for you. Works well.

                 xRemoteFile FileDownload
                    {
                        Uri = $packageUri
                        DestinationPath = $packageOutFile
                        MatchSource = $true
                        DependsOn=""
                    }

If your downloading sensitive data, your going to want to ensure you store that in a blob store with restricterd access, and then generate a SAS token to use in your URL here.