Hi all, I have a question about the prefect-azure...
# prefect-integrations
d
Hi all, I have a question about the prefect-azure integration, specifically using the
AzureBlobStorageContainer
block. I have the block registered on prefect as shown in the attached screenshot. Referring to the code snipped there, I create block stores to use in my tasks and flows as follows:
Copy code
from prefect_azure import AzureBlobStorageContainer, AzureBlobStorageCredentials


def prefect_block(block_name, base_folder=None):
    try:
        return AzureBlobStorageContainer.load(block_name)
    except ValueError:
        creds_block = AzureBlobStorageCredentials(connection_string=conn_str)
        try:
            creds_block = creds_block.load(name="creds_block")
        except ValueError:
            creds_block.save(name=f"creds_block")
            creds_block = creds_block.load(name="creds_block")
        
        azure_block = AzureBlobStorageContainer(container_name=container, credentials=creds_block, base_folder=base_folder)
        azure_block.save(name=block_name)
        return AzureBlobStorageContainer.load(block_name)
I then specify the necessary result store for my tasks like so:
Copy code
RESULT_STORE = prefect_block("common-result-store", "common/data/result_store")

@task(result_storage=RESULT_STORE)
def foo():
    ...

@flow(result_storage=RESULT_STORE)
def bar():
    ...
For my flow I am using
task_runner=DaskRunner
. On running my flow I get the following error in one of the tasks:
Copy code
TypeError: Result storage configuration must be persisted server-side. Please call `.save()` on your block before passing it in.
a
Hey @Dhruv Laad! Can you share what version of
prefect
you have installed?
d
@alex sure!
Copy code
Version:             3.1.9
API version:         0.8.4
Python version:      3.10.12
Git commit:          e1fe7943
Built:               Fri, Dec 20, 2024 4:33 PM
OS/Arch:             linux/x86_64
Profile:             local
Server type:         server
Pydantic version:    2.9.2
Integrations:
  prefect-dask:      0.3.2
  prefect-azure:     0.4.2
a
Thanks! Looks like you're on the most recent version, so it'd be great if you could create an issue for this in GitHub. It looks like the block serialization when going to Dask is dropping some info. As a workaround, you can pass in the block slug like this
@task(result_storage="azure-blob-storage-container/common-result-store")
.
d
I will try this out right away. Looks similar to this discussion if I am not wrong? I will also open an issue on Github for the same
a
Ah, yeah it looks like you aren't the first one to run into this. This existing issue looks similar: https://github.com/PrefectHQ/prefect/issues/15794. Could you comment on that thread with your usecase? I suspect both cases share the same root cause.
d
added to that issue. do you want any more info in the comment?
a
Thank! I think there's enough info to reproduce, so what you posted is great!
d
btw using the slugs worked. thanks for your reply, i can finally go to sleep lol
😅 1