microsoft / durabletask-java

Java SDK for Durable Functions and the Durable Task Framework
MIT License
13 stars 7 forks source link

Azure Durable Function Secret Key changes every time I run durable function on local #124

Closed kanupriya15025 closed 1 year ago

kanupriya15025 commented 1 year ago

I have been trying to raise an event on my orchestrator function on my local. When I create the orchestrator function, the REST API returns a list of HTTP calls that has "code" appended as one the query params.

If during this process my durable function setup restart, and I try the same REST API for raising event, the orchestrator instance doesn't pick it up. However it runs fine if the function app didn't restart.

What I could figure out is that, after the restart if I create another instance, the HTTP methods returned have a different code this time and if I append this for my previous orchestrator, it works. I suspect that the code is changing on every restart.

Is there a way that I can keep the "code" static or a good way to generate it on the fly that will work for all?

PS : This raiseEvent is happening from another Java application.

kanupriya15025 commented 1 year ago

Bump on this issue @ChrisRomp

ChrisRomp commented 1 year ago

Hi @kanupriya15025 - These are the Functions Access Keys, specifically the System Key created by the durable task extension. Doing some quick testing locally, if you're using the local storage emulator (i.e., Azurite or similar) then that storage can be ephemeral, so when it's regenerated it will generate a new host.json (in storage) including new systemKeys for durabletask_extension.

To prevent the key from rotating locally, you might be able to override the secrets store for the local functions runtime. An easier approach is to point your AzureWebJobsStorage value from local.settings.json to use a storage account in Azure, which will persist over time. If using a persistent storage provider, you should see the key(s) remain unchanged between different sessions.

One additional note, with the Azurite storage provider locally I wasn't seeing the key change between function host restarts, but only when I would restart/cleanup the Azurite files would I see the code change.

kanupriya15025 commented 1 year ago

@ChrisRomp I am not using local storage simulator. I am using storage account and putting the connection string in my local settings.

cgillum commented 1 year ago

@kanupriya15025 by chance is your storage account getting periodically cleaned up? My understanding is that these keys are persisted in blob storage (by default) in the storage account you have configured. If those blobs get removed, new keys will be generated.

Is this just with local development? If so, can you alternatively try adding the following to local.settings.json to see if that changes the behavior?

"AzureWebJobsSecretStorageType": "Files"
microsoft-github-policy-service[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.