Created
July 10, 2015 08:20
-
-
Save DexterPOSH/ec704f0405df4a1cb78d to your computer and use it in GitHub Desktop.
sample gist to append to the configurecloudservice.ps1 (or you can add a new ps1) to access custom settings defined for the Cloud Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TRY { | |
# search for the Dll | |
Write-Verbose -Message "Creating credential object" | |
$Splathashtable = @{ | |
'Path' = "$env:windir\Microsoft.NET\assembly\"; | |
'Filter' = 'Microsoft.WindowsAzure.ServiceRuntime.dll'; | |
'Include' = '*.dll' | |
} | |
$dllfile = Get-ChildItem @Splathashtable -Recurse | Select-Object -Last 1 # selecting only one object, in case of multiple results | |
Write-Verbose -Message "ServiceRuntime dll found" | |
# add the DLL to the current PowerShell session | |
Add-Type -Path $dllfile.FullName | |
Write-Verbose -Message "ServiceRuntime dll added to the current runspace" | |
# Call the Static method on the class to retrieve the setting value | |
$Setting = [Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment]::GetConfigurationSettingValue('TestKey') | |
Write-Verbose -Message "Fetched Username TestKey from the Service Configuration" | |
# Now use the value as you please | |
Write-Verbose -Message "Value stored in TestKey is $Setting" | |
} | |
CATCH { | |
throw $_.exception | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment