![](/img/trans.png)
[英]failure to execute dotnet core site using framework 4.6.1 on azure
[英]Failure Installing DotNet 4.6.1 via Chocolatey using DSC cChocoPackageInstaller
我正在尝试通过ARM模板和DSC在Azure中设置服务器Windows 2012 R2。 DSC脚本运行cChocoPackageInstaller来安装dotnet4.6.1(在运行cChocoInstaller之后)。 看起来像这样:
cChocoInstaller Choco
{
InstallDir = "c:\choco"
}
cChocoPackageInstaller DotNet461
{
Name = "dotnet-461"
DependsOn = "[cChocoInstaller]Choco"
}
下载了DotNet安装程序,但在运行时最终失败。 日志看起来像这样(我仅摘录了这里的错误)。
2016-06-17 13:05:52,001 [DEBUG] - Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:'C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe', statements: '/q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" '
2016-06-17 13:05:52,001 [DEBUG] - Elevating Permissions and running ["C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" /q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ]. This may take a while, depending on the statements.
2016-06-17 13:05:52,110 [DEBUG] - Setting RunAs for elevation
2016-06-17 13:05:53,487 [INFO ] - The application cannot find one of its required files, possibly
2016-06-17 13:05:53,487 [INFO ] -
2016-06-17 13:05:53,487 [INFO ] - because it was unable to create it in the folder. Please make
2016-06-17 13:05:53,487 [INFO ] -
2016-06-17 13:05:53,487 [INFO ] - sure that the folder in which this application was downloaded is
2016-06-17 13:05:53,487 [INFO ] -
2016-06-17 13:05:53,487 [INFO ] - accessible and not read-only.
2016-06-17 13:05:53,487 [INFO ] -
2016-06-17 13:05:53,503 [DEBUG] - Command ["C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" /q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ] exited with '3'.
2016-06-17 13:05:53,518 [ERROR] - ERROR: Running ["C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" /q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ] was not successful. Exit code was '3'. See log for possible error messages.
2016-06-17 13:05:53,518 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'c:\choco\helpers\chocolateyInstaller.psm1'; & 'c:\choco\helpers\chocolateyScriptRunner.ps1' -packageScript 'c:\choco\lib\dotnet-461\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '3'.
2016-06-17 13:05:53,534 [DEBUG] - Calling command ['"C:\Windows\System32\shutdown.exe" /a']
2016-06-17 13:05:53,549 [DEBUG] - Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'
有几件事:
任何想法表示赞赏。 谢谢!
很抱歉延迟。 因此,您需要拥有一个自动化帐户。 我已经修改了模板部署脚本以创建自动化帐户,然后使用Get-AzureRmAutomationRegistrationInfo cmdlet,我得到了主键和端点,如下所示:
$RegistrationInfo = Get-AzureRmAutomationRegistrationInfo `
-ResourceGroupName $ResourceGroupName `
-AutomationAccountName $AccountName
New-AzureRmResourceGroupDeployment `
-Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) `
-ResourceGroupName $ResourceGroupName -TemplateFile $TemplateFile `
-TemplateParameterFile $TemplateParametersFile `
# extra params here
-RegistrationKey ($RegistrationInfo.PrimaryKey | ConvertTo-SecureString -AsPlainText -Force) `
-RegistrationUrl $RegistrationInfo.Endpoint `
-AutomationAccountName $AccountName
然后,在模板本身中,您在那里也有一个自动化帐户(来自param的名称),并且作为其子资源,配置和编译。
请参阅此处以获取模板和配置的自动化帐户部分。 (最近我在v上做了同样的事情,但有问题,但最终还是有效。)如您所见,配置是一个脚本,可以下载.net安装程序并进行安装。 仅供参考,这需要重新启动,因此,如果在部署期间在虚拟机上进行任何其他操作,则可能会发生冲突。
就像我说的那样,如果需要,您还可以使用自定义脚本扩展名来实现。 Msft在服务探查器站点上具有执行此操作的脚本:
{
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.7",
"autoUpgradeMinorVersion": false,
"settings": {
"fileUris": [ "https://serviceprofiler.azurewebsites.net/content/downloads/InstallNetFx46.ps1" ],
"commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File InstallNetFx46.ps1"
},
"forceUpdateTag": "RerunExtension"
},
"name": "CustomScriptExtensionInstallNet46"
}
并不是说这是最好的答案,但是,当从其中一个启动时,通过Chocolatey(直接从CustomScript ARM扩展启动)或DSC(使用拉网服务器和.Net 4.6.1的自定义DSC模块)都可以使用。 ARM模板。 下面是我的ChocolateyInstall.ps1。 我基本上是手动执行安装,而不是依靠巧克力式安装功能。 这来自以下SO问题 ,该问题在4.5.2中使用了此方法。
Function IsInstalled {
$ver = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').Release
return (!($ver -eq $null) -and ($ver -ge 394254))
}
if (IsInstalled) {
Write-Host "Microsoft .NET Framework 4.6.1 or later is already installed"
}
else {
$SourceURI = "https://download.microsoft.com/download/3/5/9/35980F81-60F4-4DE3-88FC-8F962B97253B/NDP461-KB3102438-Web.exe"
$FileName = $SourceURI.Split('/')[-1]
$BinPath = Join-Path $env:SystemRoot -ChildPath "Temp\$FileName"
if (!(Test-Path $BinPath))
{
Invoke-Webrequest -Uri $SourceURI -OutFile $BinPath
}
write-verbose "Installing .Net 4.6.1 from $BinPath"
write-verbose "Executing $Binpath /q /norestart"
Sleep 5
Start-Process -FilePath $BinPath -ArgumentList "/q /norestart" -Wait -NoNewWindow
Sleep 5
Write-Verbose "DotNet 4.6.1 Install completed"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.