无法在天蓝色VM上访问DSC中新连接的磁盘

时间:2018-01-24 19:54:53

标签: azure virtual-machine dsc

我遇到了一个DSC配置问题,我试图在Azure VM上安装和运行mongo服务。

当DSC在初始部署VM时运行时,辅助磁盘“F' F'已成功附加和格式化,但是...尝试在新磁盘上创建目录时收到错误:

function getHash(user) {
  return new Promise((resolve, reject) => {
    bcrypt.genSalt(saltRounds, (err,salt) => {
      bcrypt.hash(user.get('password'),salt, (err,hash) => {
        resolve(hash);
      });
    });
  });
}

User.addHook('beforeCreate', (user,options) => {
    console.log('hook fired');
    console.log(user);
    return getHash(user)
      .then(hash => user.set('password', hash))
});

这是我的DSC脚本:

Error message: \"DSC Configuration 'Main' completed with error(s).
Cannot find drive. A drive with the name 'F' does not exist. 
The PowerShell DSC resource '[Script]SetUpDataDisk' with SourceInfo 'C:\\Packages\\Plugins\\Microsoft.Powershell.DSC\\2.73.0.0\\DSCWork\\MongoDSC.0\\MongoDSC.ps1::51::2::Script' threw one or more non-terminating errors while running the Set-TargetResource functionality. 

令人讨厌的是,如果我再次运行部署,一切都没有错误,我已经放入一个循环尝试等待磁盘准备好,但这仍然会引发错误。我对DSC很新,所以任何指针都会有所帮助。

1 个答案:

答案 0 :(得分:1)

似乎可以使用 xDiskAccessPath

<#
    .EXAMPLE
        This configuration will wait for disk 2 to become available, and then make the disk available as
        two new formatted volumes mounted to folders c:\SQLData and c:\SQLLog, with c:\SQLLog using all
        available space after c:\SQLData has been created.
#>
Configuration Example
{

    Import-DSCResource -ModuleName xStorage

    Node localhost
    {
        xWaitforDisk Disk2
        {
             DiskId = 2
             RetryIntervalSec = 60
             RetryCount = 60
        }

        xDiskAccessPath DataVolume
        {
             DiskId = 2
             AccessPath = 'c:\SQLData'
             Size = 10GB
             FSLabel = 'SQLData1'
             DependsOn = '[xWaitForDisk]Disk2'
        }

        xDiskAccessPath LogVolume
        {
             DiskId = 2
             AccessPath = 'c:\SQLLog'
             FSLabel = 'SQLLog1'
             DependsOn = '[xDiskAccessPath]DataVolume'
        }
    }
}

https://github.com/PowerShell/xStorage/blob/dev/Modules/xStorage/Examples/Resources/xDiskAccessPath/1-xDiskAccessPath_InitializeDataDiskWithAccessPath.ps1