microsoft / promptflow

Build high-quality LLM apps - from prototyping, testing to production deployment and monitoring.
https://microsoft.github.io/promptflow/
MIT License
9.53k stars 872 forks source link

[BUG] Azure AI Search connection not copied with docker build #3803

Closed teebu closed 1 week ago

teebu commented 1 month ago

Describe the bug Creating a docker image to deploy with open ai connection and azure ai search connection.

Note: running this flow from inside VS code works fine when I am logged in (az login, etc).

How To Reproduce the bug Steps to reproduce the behavior, how frequent can you experience the bug: Create chat flow. Export the flow locally In VS code create connections for open ai deployment and azure ai search Build the flow pf flow build --source . --output dist--format docker Inspect the dist/connections directory and observe that the AI Search connection is missing

Expected behavior Ability to run flows from inside docker container image

Screenshots If applicable, add screenshots to help explain your problem.

Running Information(please complete the following information):

Additional context

Things I tried:

Manually created connection for azure ai search yaml (AzureAISearch.yaml) with ENV passing when starting docker.

$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CognitiveSearchConnection.schema.json
name: AzureAISearch
type: cognitive_search
api_key: ${env:AZURE_AI_SEARCH_API_KEY}
api_base: 'endpoint'
api_version: '2023-11-01'

set service.provider=local and set connection file in run file:

pf connection create --file /connections/AzureAISearch.yaml
pf config set connection.provider=local

Error logs:

INFO:azureml.rag.connections:Getting workspace connection: AzureAISearch, with input credential: <class 'NoneType'>.
2024-10-08 02:13:29 +0000      59 execution.flow     INFO     [querySearchResource in line None (index starts from 0)] stdout> [2024-10-08 02:13:29] INFO     azureml.rag.connections - Using ml_client base_url: https://management.azure.com, original_base_url: https://management.azure.com. (connections.py:367)
WARNING:azure.identity._credentials.chained:DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
        EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.
        AzureCliCredential: Azure CLI not found on path
        AzurePowerShellCredential: PowerShell is not installed
        AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://aka.ms/azure-dev for installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
2024-10-08 02:13:29 +0000      59 promptflow_vectordb.tool INFO     [index_lookup_tool] `search_function_construction` completed in 5.750510728001245 seconds.
2024-10-08 02:13:29 +0000      59 execution.flow     INFO     [querySearchResource in line None (index starts from 0)] stdout> [2024-10-08 02:13:29] INFO     azureml.rag.index_lookup_tool(Promptflow) - `search_function_construction` completed in 5.750510728001245 seconds. (profiling.py:29)
INFO:azureml.rag.index_lookup_tool(Promptflow):`search_function_construction` completed in 5.750510728001245 seconds.
2024-10-08 02:13:29 +0000      59 promptflow_vectordb.tool ERROR    [index_lookup_tool]
Traceback (most recent call last):
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/promptflow_vectordb/tool/utils/profiling.py", line 18, in measure_execution_time
    yield
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/promptflow_vectordb/tool/common_index_lookup.py", line 54, in _get_search_func
    search_func = build_search_func(index, top_k, query_type)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/promptflow_vectordb/tool/common_index_lookup_extensions/utils.py", line 35, in build_search_func
    store = index.as_langchain_vectorstore()
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azureml/rag/mlindex.py", line 186, in as_langchain_vectorstore
    raise e
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azureml/rag/mlindex.py", line 172, in as_langchain_vectorstore
    connection_credential = get_connection_credential(self.index_config, credential=credential)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azureml/rag/utils/connections.py", line 78, in get_connection_credential
    connection = get_connection_by_id_v2(connection_id, credential=credential)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azureml/rag/utils/__init__.py", line 55, in wrapper
    raise e
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azureml/rag/utils/__init__.py", line 49, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azureml/rag/utils/connections.py", line 373, in get_connection_by_id_v2
    list_secrets_response = ml_client.connections._operation.list_secrets(
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/ai/ml/_restclient/v2024_04_01_preview/operations/_workspace_connections_operations.py", line 775, in list_secrets
    pipeline_response = self._client._pipeline.run(  # pylint: disable=protected-access
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 230, in run
    return first_node.send(pipeline_request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 86, in send
    response = self.next.send(request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 86, in send
    response = self.next.send(request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 86, in send
    response = self.next.send(request)
  [Previous line repeated 2 more times]
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/mgmt/core/policies/_base.py", line 46, in send
    response = self.next.send(request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/policies/_redirect.py", line 197, in send
    response = self.next.send(request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/policies/_retry.py", line 531, in send
    response = self.next.send(request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/policies/_authentication.py", line 124, in send
    self.on_request(request)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/core/pipeline/policies/_authentication.py", line 99, in on_request
    self._token = self._credential.get_token(*self._scopes)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/identity/_credentials/default.py", line 225, in get_token
    token = super().get_token(*scopes, claims=claims, tenant_id=tenant_id, **kwargs)
  File "/opt/conda/envs/promptflow-serve/lib/python3.9/site-packages/azure/identity/_credentials/chained.py", line 124, in get_token
    raise ClientAuthenticationError(message=message)
azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
        EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.
        AzureCliCredential: Azure CLI not found on path
        AzurePowerShellCredential: PowerShell is not installed
        AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://aka.ms/azure-dev for installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.

For some reason it expects me to be logged into azure. But, im trying to make a docker image.

luigiw commented 1 month ago

Looks like this is from the promptflow_vectordb tool?

teebu commented 1 month ago

Yea

- name: querySearchResource
  type: python
  source:
    type: package
    tool: promptflow_vectordb.tool.common_index_lookup.search
github-actions[bot] commented 2 weeks ago

Hi, we're sending this friendly reminder because we haven't heard back from you in 30 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 7 days of this comment, the issue will be automatically closed. Thank you!