I have an app service running with it's respective ConnectionString from Azure Portal. The ConnectionString is point to Azure SQL Server.
I have a WebJob with the following appsettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Add your connection string"
}
}
When I run the Web Job, it doesn't seem to pull the Connection strings from the azure portal, but it uses my default ConnectionStrings in appsettings.json.
[02/13/2017 08:45:27 > 2942c6: SYS INFO] Status changed to Initializing
[02/13/2017 08:45:27 > 2942c6: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[02/13/2017 08:45:27 > 2942c6: SYS INFO] Status changed to Running
[02/13/2017 08:45:27 > 2942c6: INFO]
[02/13/2017 08:45:27 > 2942c6: INFO] D:\local\Temp\jobs\triggered\TestConnectionString\32vmiek4.2av>dotnet TestConnectionString.dll
[02/13/2017 08:45:29 > 2942c6: INFO] Add your connection string
Azure WebJobs are deprecated, but still in use. They are being phased out in favor of Azure Functions. Azure Functions is a more up-to-date and feature rich service which offers a greater degree of flexibility and control.
If you set the web app that hosts your job to run continuously, run on a schedule, or use event-driven triggers, enable the Always on setting on your web app's Azure Configuration page. The Always on setting helps to make sure that these kinds of WebJobs run reliably.
Summary. Azure Functions offers more developer productivity than Azure App Service WebJobs does. It also offers more options for programming languages, development environments, Azure service integration, and pricing. For most scenarios, it's the best choice.
Make sure you call AddEnvironmentVariables()
when building your configuration. e.g.
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With