Jonathan Sayce
Jonathan Sayce

Reputation: 9679

Different connection string for Azure web app and web job

I've got an Azure web app, with a web job that uses the same database context, so by convention they pick up the same connection string name. They currently get the connection string from the web app application settings, to avoid having passwords stored in the config file.

I'm trying to improve security by setting up separate database users for the web app and web job, which need different levels of access, but given that they share the same context, I'm not sure how to get them to pick up different connection strings from the Azure application settings.

What's the best way to do this? The only option I can see is specifying the connection string every time the context is instantiated, but this seems like a bit of a pain.

Upvotes: 1

Views: 386

Answers (1)

David Ebbo
David Ebbo

Reputation: 43203

I don't think there is a great solution to this. Possible workarounds:

  • Don't use the same connection string name for both. e.g. maybe you can have an app setting that tells you the connections name to use. And you'd keep that app setting different in the app and webjob (you can hard code that in their respective configs).
  • Host them in different Azure Web Apps

Upvotes: 4

Related Questions