What’s the best way to persist a variable between Azure WebJob runs?

0
0
Asked By MellowPine42 On

I'm still getting familiar with Azure Storage and need a simple, reliable way to save a variable's state so it can be loaded the next time an Azure WebJob runs. I initially tried writing the value to a local file from the process, but the environment doesn't allow that. Should I use Blob Storage, Table Storage, or another Azure service?

3 Answers

Answered By SilverKite63 On

If this is a long-running or asynchronous workflow rather than a simple scheduled job, Durable Functions may be worth considering. They provide built-in patterns for checkpoints and persisted orchestration state. For a basic WebJob variable, though, Blob or Table Storage should be enough.

Answered By CobaltRaven7 On

For a single value, Blob Storage is probably the simplest option. Your WebJob can read the state from a blob when it starts and write the updated value when it finishes. For example, you could use the connection string from the AzureWebJobsStorage environment variable, load the current value, do the work, and then save the new value. Local files aren’t reliable for WebJobs because the filesystem may be restricted or temporary.

MellowPine42 -

Thank you so much! That clears up why the file-based approach wasn’t working.

Answered By JuniperFox19 On

Blob Storage works well for one small piece of state. If you need several structured fields, multiple records, or to query values, Azure Table Storage is usually a better fit. It gives you a simple key-value style data store without requiring a full database.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.