我有一个 ARM 模板,它执行所需状态配置扩展以安装和配置 IIS。但是,我需要安装和配置一些区域,这要求我已经安装了其他工具。
ARM 模板
{
"name": "Microsoft.Powershell.DSC",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.20",
"autoUpgradeMinorVersion": true,
"forceUpdateTag":"v.4.2",
"settings": {
"wmfVersion": "latest",
"configuration": {
"url": "[concat(variables('dscArtifactsLocation'), '/', variables('dscExtensionArchiveFolder'),'/IISInstall.ps1.zip')]",
"script": "IISInstall.ps1",
"function": "IISInstall"
},
"configurationArguments": {
"nodeName": "localhost"
}
},
"protectedSettings": {
"configurationUrlSasToken": "?TOKEN"
}
}
}
IISInstall.ps1
Node $nodeName
{
WindowsFeature IIS
{
Ensure = "Present"
Name = "Web-Server"
}
WindowsFeature AspNet45
{
Ensure = "Present"
Name= "Web-Asp-Net45"
}
}
例如,我希望能够使用xWebAdministration
,但这要求我先安装它,然后才能调用
Import-DscResource -ModuleName xWebAdministration
此外,我需要安装 IISUrlRewrite v2,计划是使用 Chocolately,但这也需要安装才能使用它来安装程序。是否可以“引导”DSC 执行?
最佳答案
目前似乎不支持此功能,因为 scaleset
扩展并行运行。可能首选选项是在通过 custom script extension 运行的 powershell 脚本中实现 Bootstrap
您可以创建存储在 blobstorage 中的多个单独的 powershell 脚本,并使用 &&
分隔调用它们
以下是在部署 dotnet.core 之前通过 powershell 将新 HDD 添加到规模集实例的示例。
{
“名称”:“[concat(变量('vmNodeTypeAppName'),'_InitializeVM')]”,
“特性”: {
"出版商": "微软.Compute",
“设置”: {
“fileUris”:[“https://dot.net/v1/dotnet-install.ps1”]
},
"typeHandlerVersion": "1.8",
“autoUpgradeMinorVersion”:true,
“ protected 设置”:{
“执行命令”:
“powershell.exe -ExecutionPolicy Unrestricted -Command\”获取磁盘|其中partitionstyle -eq 'raw' |初始化磁盘-分区样式MBR-PassThru |新分区-DriveLetter F-UseMaximumSize |格式卷 -FileSystem NTFS -NewFileSystemLabel DataDisk -Confirm:$false\"&& powershell.exe -ExecutionPolicy Unrestricted -File dotnet-install.ps1 -SharedRuntime"
},
“类型”:“自定义脚本扩展”
}
}
关于powershell - 适用于 Azure Arm 模板的 Bootstrap DSC 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46604537/