Azure:从startup.cmd访问ServiceConfiguration.cscfg?

Ali*_*Ali 1 azure

有谁知道是否可以从角色的startup.cmd访问ServiceConfiguration.cscfg?

ServiceConfiguration.cscfg是否放置在角色的物理VM上的任何位置?

谢谢!

maa*_*nba 7

创建一个启动PowerShell脚本的启动脚本:

powershell.exe Set-ExecutionPolicy Unrestricted
powershell.exe .\mypsscript.ps1 >> ..\startup-tasks-log.txt 2>>..\startup-tasks-error-log.txt
Run Code Online (Sandbox Code Playgroud)

然后,在PowerShell脚本中,您可以轻松访问RoleEnvironment类(以及配置值):

[Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime")

$roleInstanceId = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id
$appTitle = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::GetConfigurationSettingValue("AppTitle")
Run Code Online (Sandbox Code Playgroud)

等等