Skip to content

Azure Cognitive Search: SearchResourceEncryptionKey raises 'not iterable' error during data source connection creation in azure-search-documents SDK (v11.6.0b4)) #37251

Closed

Description

  • Package Name: azure.search.documents
  • Package Version: 11.6.0b4
  • Operating System: OSX, version: 14.6.1
  • Python Version: 3.9.6

Describe the bug
When attempting to use the azure-search-documents SDK, the encryption key provided is not accepted due to a type mismatch.
The SDK does not handle the type correctly, leading to a failure during deserialization when creating the data source connection. As according to the Microsoft documentation, SearchResourceEncryptionKey object is passed, but an error arises, where an iterable type is expected for encryption key.

Microsoft docs: https://learn.microsoft.com/en-us/python/api/azure-search-documents/azure.search.documents.indexes.models.searchindexerdatasourceconnection?view=azure-python
Python Library: https://pypi.org/project/azure-search-documents/11.5.0/

To Reproduce
Steps to reproduce the behaviour:
Assuming Blob Storage Account , AI Search, Index and indexer all already exists and managed identity enabled.

  1. Install the library azure-search-documents==11.6.0b4
  2. Define SearchResourceEncryptionKey object for encryption.
  3. Create Indexer client.
  4. Define data source connection passing SearchResourceEncryptionKey object defined earlier.
  5. Attempt to create a data source connection for ab indexer.
  6. Observe the "not iterable" error during the deserialization process.
from azure.search.documents.indexes import SearchIndexerClient
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes.models import SearchIndexerDataSourceConnection, SearchResourceEncryptionKey

# Initialize the client
indexer_client = SearchIndexerClient(endpoint="https://<your-search-service>.search.windows.net",
                             credential=AzureKeyCredential("<your-key>"))

# Define an encryption key
encryption_key = SearchResourceEncryptionKey(
    key_name="your-key-name",
    key_version="your-key-version",
    vault_uri="https://<your-keyvault-name>.vault.azure.net/",
    application_id="<your-client-app-id>",
    application_secret="<your-server-app-secret>",
)

# Attempt to create a data source connection for an indexer
data_source_connection = SearchIndexerDataSourceConnection(
    name="my-datasource",
    type="azureblob",
    connection_string=<your-blob-managed-identity-connection-string>,
    container=SearchIndexerDataContainer(name=<your-container>, query=<your-folder-path>)
    encryption_key=encryption_key  # Pass SearchResourceEncryptionKey
)

try:
    indexer_client.create_or_update_data_source_connection(data_source_connection)
except Exception as e:
    print(f"Failed to create data source connection: {e}")

Expected behaviour
The SDK should correctly handle the SearchResourceEncryptionKey when creating a data source connection for an indexer.

Actual behaviour
The operation fails with a "not iterable" error, suggesting that the SDK is not properly handling the SearchResourceEncryptionKey object during deserialization.

Error Message I receive:

connector: <aiohttp.connector.TCPConnector object at 0x13f764340>
<class 'azure.search.documents.indexes.models._models.SearchResourceEncryptionKey'>
--- Logging error ---
Traceback (most recent call last):
  File "/Users/redacted-project-path/.venv/lib/python3.9/site-packages/azure/search/documents/indexes/_generated/_serialization.py", line 1461, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/Users/redacted-project-path/.venv/lib/python3.9/site-packages/azure/search/documents/indexes/_generated/_serialization.py", line 1230, in rest_key_case_insensitive_extractor
    return attribute_key_case_insensitive_extractor(key, None, working_data)
  File "/Users/redacted-project-path/.venv/lib/python3.9/site-packages/azure/search/documents/indexes/_generated/_serialization.py", line 1257, in attribute_key_case_insensitive_extractor
    for key in data:
TypeError: 'SearchResourceEncryptionKey' object is not iterable```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Searchcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions