我尝试过以下示例从Azure blob或Azure文件共享下载,但从未让它工作。有没有办法将文件下载到VM传递凭据或密钥?
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
}
}
我也尝试过使用文件模块。
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
}
}
答案 0 :(得分:1)
如果从Azure文件共享下载文件,则可以参考此example。将以下脚本添加到脚本中。
Configuration SimpleExampleWithCredentials {
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[PSCredential]$Credentials
)
如果使用经典VM,则可以使用以下cmdlet。
Set-AzureVMDscExtension -VM $vm -ConfigurationArchive MyConfiguration.ps1.zip -ConfigurationName MyConfiguration -ConfigurationArgument @{ storageCredential= (Get-Credential) }
如果使用ARM VM,则应使用cmdlet Set-AzureRmVMDscExtension。