{"record":{"id":"a15815297674e14c","repo":"stanford-oval/storm","slug":"azureaisearch-requires-pip-install-azure-search-d","errorCode":null,"errorMessage":"AzureAISearch requires `pip install azure-search-documents`.","messagePattern":"AzureAISearch requires `pip install azure-search-documents`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/rm.py","lineNumber":1141,"sourceCode":"        \"\"\"\n        Params:\n            azure_ai_search_api_key: Azure AI Search API key. Check out https://learn.microsoft.com/en-us/azure/search/search-security-api-keys?tabs=rest-use%2Cportal-find%2Cportal-query\n                \"API key\" section\n            azure_ai_search_url: Custom Azure AI Search Endpoint URL. Check out https://learn.microsoft.com/en-us/azure/search/search-create-service-portal#name-the-service\n            azure_ai_search_index_name: Custom Azure AI Search Index Name. Check out https://learn.microsoft.com/en-us/azure/search/search-how-to-create-search-index?tabs=portal\n            k: Number of top results to retrieve.\n            is_valid_source: Optional function to filter valid sources.\n            min_char_count: Minimum character count for the article to be considered valid.\n            snippet_chunk_size: Maximum character count for each snippet.\n            webpage_helper_max_threads: Maximum number of threads to use for webpage helper.\n        \"\"\"\n        super().__init__(k=k)\n\n        try:\n            from azure.core.credentials import AzureKeyCredential\n            from azure.search.documents import SearchClient\n        except ImportError as err:\n            raise ImportError(\n                \"AzureAISearch requires `pip install azure-search-documents`.\"\n            ) from err\n\n        if not azure_ai_search_api_key and not os.environ.get(\n            \"AZURE_AI_SEARCH_API_KEY\"\n        ):\n            raise RuntimeError(\n                \"You must supply azure_ai_search_api_key or set environment variable AZURE_AI_SEARCH_API_KEY\"\n            )\n        elif azure_ai_search_api_key:\n            self.azure_ai_search_api_key = azure_ai_search_api_key\n        else:\n            self.azure_ai_search_api_key = os.environ[\"AZURE_AI_SEARCH_API_KEY\"]\n\n        if not azure_ai_search_url and not os.environ.get(\"AZURE_AI_SEARCH_URL\"):\n            raise RuntimeError(\n                \"You must supply azure_ai_search_url or set environment variable AZURE_AI_SEARCH_URL\"\n            )","sourceCodeStart":1123,"sourceCodeEnd":1159,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/rm.py#L1123-L1159","documentation":"Raised by AzureAISearchRM.__init__ when the optional Azure SDK packages (azure-core, azure-search-documents) are not installed. STORM treats Azure AI Search retrieval as an optional extra, so it only imports the SDK lazily inside the constructor and converts the ImportError into a clearer message with install instructions.","triggerScenarios":"Instantiating AzureAISearchRM on an environment where `import azure.search.documents` or `import azure.core.credentials` fails — i.e., azure-search-documents (and its azure-core dependency) were never installed or were removed from the virtualenv.","commonSituations":"Installing the storm/knowledge-storm package without optional extras; using a different virtualenv/conda env than the one where the Azure SDK was installed; a broken or partially uninstalled azure namespace package causing ImportError even though some azure-* packages exist.","solutions":["pip install azure-search-documents","Verify you're in the right environment: python -c \"import azure.search.documents\"","If it still fails, reinstall cleanly: pip install --force-reinstall azure-search-documents azure-core"],"exampleFix":"# before\nrm = AzureAISearchRM(azure_ai_search_api_key=..., azure_ai_search_url=..., azure_ai_search_index_name=...)\n\n# after\npip install azure-search-documents\nrm = AzureAISearchRM(azure_ai_search_api_key=..., azure_ai_search_url=..., azure_ai_search_index_name=...)","handlingStrategy":"validation","validationCode":"def azure_search_sdk_available():\n    try:\n        import azure.search.documents  # noqa: F401\n        import azure.core.credentials  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif not azure_search_sdk_available():\n    raise SystemExit(\"Install with: pip install azure-search-documents\")","typeGuard":null,"tryCatchPattern":"try:\n    from knowledge_storm.rm import AzureAISearchRM\n    rm = AzureAISearchRM(azure_ai_search_api_key=K, azure_ai_search_url=U, azure_ai_search_index_name=I)\nexcept ImportError as e:\n    if \"azure-search-documents\" in str(e):\n        # fall back to another retriever or prompt the user to install\n        rm = YouRM(...)\n    else:\n        raise","preventionTips":["Declare azure-search-documents in your project's requirements when using AzureAISearchRM","Pin optional extras in setup/pyproject extras_require so CI installs them","Add a smoke test that imports the SDK in the deployment environment"],"tags":["azure","optional-dependency","import-error","pip-install"],"backgroundTag":"missing-optional-dependency","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}