2
votes

I've created a web job and publishing it using VS2013 to existing web app. But the configuration values of my web job app.config is not appearing in azure portal configuration tab. I do not want to manually enter config values in azure portal plus I do not want my web site to have those values. Any thoughts?

I also tried deploying using powershell cmdlets New-AzureWebsiteJob but it does not accept app config. Only option I see is using powershell to read app.config and push config values using Set-AzureWebSite cmdlet.

2
You're right that it isn't an option to set the App's App Settings during Publish for WebJobs. I'll take this feedback to the team. I think your PowerShell script sounds like it's the logical solution to your problem. If you write the PS script, you should post it as an answer in case someone is in the same scenario as you.Chris Anderson-MSFT
Thanks for quick response!Balvinder Singh

2 Answers

1
votes

Okay, so this is how I solved it. Happy to hear if there is any better solution.

$path = "<web job app.config file path>"
$xml = [xml](Get-Content $path)
$appSettings = @{}
$connectionStrings = (Get-AzureWebsite -Name "MyWebApp").ConnectionStrings

$xml.configuration.connectionStrings.add | ForEach-Object { $connectionStrings.Add(@{Name=$_.name; ConnectionString=$_.connectionString; Type="custom"})}

$xml.configuration.appSettings.add | ForEach-Object { $appSettings.Add($_.key, $_.value) }

Set-AzureWebsite -Name "MyWebApp" -ConnectionStrings $connectionStrings -AppSettings $appSettings
0
votes

Settings in an App.Config or Web.Config do not show up in the portal at all. But anything set in the portal will override any settings in those files. So you do not have to set them in the portal at all if you don't want to.