I've tried the following example to download from Azure blob or Azure file share but never got it to work. Is there a way to download files to VM passing credentials or keys?
Import-DSCResource -ModuleName PSDesiredStateConfiguration, xPSDesiredStateConfiguration
Node webServer
{ xRemoteFile Installs
{
DestinationPath = "C:\Scripts"
Credential = $StorageCredential
Ensure = "Present"
SourcePath = "https://storagename.blob.core.windows.net/installs"
Type = "Directory"
Recurse = $true
}
}
I also tried the using File module.
Import-DSCResource -ModuleName PSDesiredStateConfiguration, xPSDesiredStateConfiguration
Node webServer
{
File Installs
{
DestinationPath = "C:\Scripts"
Credential = $StorageCredential
Ensure = "Present"
SourcePath = "\\storagename.file.core.windows.net\installs"
Type = "Directory"
Recurse = $true
}
}
If you download file from Azure File Share, you could refer to this example . Add following script to your script.
Configuration SimpleExampleWithCredentials {
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[PSCredential]$Credentials
)
If you use classic VM, you could use the following cmdlets.
Set-AzureVMDscExtension -VM $vm -ConfigurationArchive MyConfiguration.ps1.zip -ConfigurationName MyConfiguration -ConfigurationArgument @{ storageCredential= (Get-Credential) }
If you use ARM VM, you should use cmdlet Set-AzureRmVMDscExtension .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.