When registering my flow, I get an error: ValueError: Local Secret "AZURE_STORAGE_CONNECTION_STRING" was not found

This error indicates that Prefect tries to find the Secret locally. To instead use a Secret stored in the Prefect Cloud backend, you need to export the following environment variable to let Prefect know that it should use Secrets from Prefect Cloud rather than a local secret:

export PREFECT__CLOUD__USE_LOCAL_SECRETS=false

If you are on Windows, use:

set PREFECT__CLOUD__USE_LOCAL_SECRETS=false

Using local secret

If your intention is to use local Secret instead, you can configure the local Secret for Azure storage as follows:

export PREFECT__CONTEXT__SECRETS__AZURE_STORAGE_CONNECTION_STRING="your_token"

If you are on Windows, use:

set PREFECT__CONTEXT__SECRETS__AZURE_STORAGE_CONNECTION_STRING="your_token"

Using a different Secret name

By default, Prefect is looking for a secret named AZURE_STORAGE_CONNECTION_STRING. If you want to use a different name for the Secret, you can configure that using the argument connection_string_secret:

from prefect import Flow
from prefect.storage import Azure

flow = Flow(
    "azure-flow",
    storage=Azure(
        container="<your-container>",
        connection_string_secret="<name-of-your-prefect-secret>",
    ),
)

flow.storage.build()

For more information, check out this documentation page.