Ali
Ali

Reputation: 1286

Azure: access ServiceConfiguration.cscfg from startup.cmd?

Does anyone know if it is possible to access the ServiceConfiguration.cscfg from the startup.cmd of a role?

Is the ServiceConfiguration.cscfg placed any where on the physical VM of the role?

Thanks!

Upvotes: 1

Views: 988

Answers (1)

maartenba
maartenba

Reputation: 3384

Create a startup script that fires a powershell script:

powershell.exe Set-ExecutionPolicy Unrestricted
powershell.exe .\mypsscript.ps1 >> ..\startup-tasks-log.txt 2>>..\startup-tasks-error-log.txt

Then, in the PowerShell script, you can easily access the RoleEnvironment class (and config values as well):

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

$roleInstanceId = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::CurrentRoleInstance.Id
$appTitle = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::GetConfigurationSettingValue("AppTitle")

etc.

Upvotes: 7

Related Questions