首页 > 解决方案 > Azure DSC 将文件从存储上传到 VM?

问题描述

我在 dsc 中使用以下代码,但它从不编译?我总是收到消息“停止:术语 'xRemoteFile' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。”

我需要通过 azure DSC 将文件从 azure 存储帐户复制到 vm。

配置 A_FILE {

Node localhost
{
    
    File SetupDir {
    Type            = 'Directory'
    DestinationPath = 'C:\files\'
    Ensure          = "Present"    
     }


   

xRemoteFile Afile {  
    Uri             = "https://storageaccountname.file.core.windows.net/files/file1.txt"
    DestinationPath = "C:\files\"
    DependsOn       = "[File]SetupDir"
    MatchSource     = $false
}

 
}

}

标签: azuredsc

解决方案


好的,我解决了

ok i worked it out

配置 getfilefromazurestorage {

导入-DscResource -ModuleName xPSDesiredStateConfiguration

Node localhost
{
          
    File SetupDir {
    Type            = 'Directory'
    DestinationPath = 'C:\localfiles'
    Ensure          = "Present"    
     }

            


    xRemoteFile remotefile {
    # for uri generate a sas token then copy the sas token url in the uri line below
    Uri             = "https://storageaccountname.blob.core.windows.net/files/sastokendetails"
    DestinationPath = "C:\localfiles\AzureFile.txt"
    DependsOn       = "[File]SetupDir"
    MatchSource     = $false
}

 
}

推荐阅读