I know it is possible to read Application Settings from a c#
WebJob in a Azure WebApp as explained in this post.
Basically you can use the ConfigurationManager
or CloudConfigurationManager
because the WebJob runs in the same WebApp context, like this:
var appSetting = ConfigurationManager.AppSettings["MyKey"];
var appCloudSetting = CloudConfigurationManager.GetSetting("MyKey");
In my scenario I'm not using a c#
application but a PowerShell script and I'm looking for a similar solution. Is it possible to read those Application Settings in a PowerShell WebJob?
When you set Azure App Settings, they become environment variables at runtime. So from your PowerShell WebJob, you can simply use:
$Env:YourAppSetting
For App Settings, try something like this:
$resource = Invoke-AzureRmResourceAction -ResourceGroupName YourResourceGroup -ResourceType Microsoft.Web/sites/config -ResourceName YourSite/appsettings -Action list -ApiVersion 2015-08-01 -Force
$resource.Properties
And for connection strings:
$resource = Invoke-AzureRmResourceAction -ResourceGroupName YourResourceGroup -ResourceType Microsoft.Web/sites/config -ResourceName YourSite/connectionstrings -Action list -ApiVersion 2015-08-01 -Force
$resource.Properties
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.