dify icon indicating copy to clipboard operation
dify copied to clipboard

STORAGE_TYPE: azure-blob, results in "Please specify a container name" error

Open zolgear opened this issue 1 year ago • 2 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.8

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Set STORAGE_TYPE to 'azure-blob'. and set AZURE_BLOB_~.
  2. Run docker compose.
  3. Observe the error message: "Please specify a container name."

image

api log:

2024-05-22 05:07:00.343 ERROR [Dummy-2] [app_service.py:97] - Please specify a container name.
Traceback (most recent call last):
  File "/app/api/services/app_service.py", line 90, in create_app
    model_instance = model_manager.get_default_model_instance(
  File "/app/api/core/model_manager.py", line 244, in get_default_model_instance
    default_model_entity = self._provider_manager.get_default_model(
  File "/app/api/core/provider_manager.py", line 227, in get_default_model
    provider_configurations = self.get_configurations(tenant_id)
  File "/app/api/core/provider_manager.py", line 118, in get_configurations
    custom_configuration = self._to_custom_configuration(
  File "/app/api/core/provider_manager.py", line 562, in _to_custom_configuration
    self.decoding_rsa_key, self.decoding_cipher_rsa = encrypter.get_decrypt_decoding(tenant_id)
  File "/app/api/core/helper/encrypter.py", line 29, in get_decrypt_decoding
    return rsa.get_decrypt_decoding(tenant_id)
  File "/app/api/libs/rsa.py", line 55, in get_decrypt_decoding
    private_key = storage.load(filepath)
  File "/app/api/extensions/ext_storage.py", line 45, in load
    return self.load_once(filename)
  File "/app/api/extensions/ext_storage.py", line 48, in load_once
    return self.storage_runner.load_once(filename)
  File "/app/api/extensions/storage/azure_storage.py", line 32, in load_once
    blob = self.client.get_container_client(container=self.bucket_name)
  File "/usr/local/lib/python3.10/site-packages/azure/storage/blob/_blob_service_client.py", line 673, in get_container_client
    return ContainerClient(
  File "/usr/local/lib/python3.10/site-packages/azure/storage/blob/_container_client.py", line 148, in __init__
    raise ValueError("Please specify a container name.")
ValueError: Please specify a container name.

https://github.com/Azure/azure-sdk-for-python/blob/ec92c6381df22b599e0b8090f17b959a643d3c84/sdk/storage/azure-storage-blob/azure/storage/blob/_container_client.py#L158

Isn't container_name required for initializing the ContainerClient class?

Untested fix. https://github.com/langgenius/dify/commit/fd0df047a3d6838a631d6deb3e18d1e17be32354

ref: #2919

✔️ Expected Behavior

Not error.

❌ Actual Behavior

No response

zolgear avatar May 22 '24 06:05 zolgear

To resolve the issue with Dify version 0.6.8 where setting STORAGE_TYPE to 'azure-blob' and running Docker compose results in the error message "Please specify a container name," ensure that the AZURE_BLOB_CONTAINER_NAME environment variable is correctly set in your docker-compose.yaml file.

Here is the relevant section of the docker-compose.yaml file with the necessary configuration:

services:
  api:
    image: langgenius/dify-api:0.6.8
    restart: always
    environment:
      STORAGE_TYPE: azure-blob
      AZURE_BLOB_ACCOUNT_NAME: 'your-account-name'
      AZURE_BLOB_ACCOUNT_KEY: 'your-account-key'
      AZURE_BLOB_CONTAINER_NAME: 'your-container-name'
      AZURE_BLOB_ACCOUNT_URL: 'https://<your_account_name>.blob.core.windows.net'
    # other configurations...

Make sure that the AZURE_BLOB_CONTAINER_NAME is specified and matches the name of your Azure Blob container. This should resolve the error message "Please specify a container name." Additionally, ensure that other Azure Blob Storage configurations such as AZURE_BLOB_ACCOUNT_NAME, AZURE_BLOB_ACCOUNT_KEY, and AZURE_BLOB_ACCOUNT_URL are correctly set as per your Azure account details.

If you have already set the AZURE_BLOB_CONTAINER_NAME and are still encountering the issue, double-check the environment variable settings in your docker-compose.yaml file and ensure there are no typos or misconfigurations. If the problem persists, verify that the environment variables are being correctly passed to the Docker container by inspecting the container's environment settings.

Details

Sources


About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

dosubot[bot] avatar May 22 '24 06:05 dosubot[bot]

@JohnJyong Please take a look at this.

crazywoola avatar May 24 '24 07:05 crazywoola

fixed #4455

I have confirmed that with v0.6.9, uploading to Azure Blob works without any issues when running on Docker localhost as well as when executing the source locally.

zolgear avatar May 28 '24 02:05 zolgear