Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyVaultUri keyVaultKeyName parameters mismatch between SearchResourceEncryptionKey and SearchIndexerSkillset results request is invalid when creating skillset in azure-search-documents SDK (v11.6.0b5) #37521

Closed
YVass1 opened this issue Sep 23, 2024 · 9 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search

Comments

@YVass1
Copy link

YVass1 commented Sep 23, 2024

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

Describe the bug
While creating a skillset for indexer for Azure AI Search, I encounter an error indicating missing parameters for the encryption key:

--- Logging error ---
  File "/Users/<redacted-project-path>/.venv/lib/python3.11/site-packages/azure/search/documents/indexes/_generated/aio/operations/_skillsets_operations.py", line 261, in create_or_update
    raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: () The request is invalid. Details: encryptionKey.keyVaultUri : The keyVaultUri field is required.
encryptionKey.keyVaultKeyName : The keyVaultKeyName field is required.
Code: 
Message: The request is invalid. Details: encryptionKey.keyVaultUri : The keyVaultUri field is required.
encryptionKey.keyVaultKeyName : The keyVaultKeyName field is required.

However, when defining parameters keyVaultUri and keyVaultKeyName from the error message in encryptionKey and removing parameters key_name and vault_uri which Microsoft documentation specifies are the available properties of class SearchResourceEncryptionKey , I get the following error (as expected):
NB: Error persisted even when these parameter name variations were tried: key_vault_uri and key_vault_key_name

Traceback (most recent call last):
  File "/Users/<redacted-project-path>/<redacted-filename>.py", line 1352, in setup_clients
    encryption_key_test = SearchResourceEncryptionKey(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SearchResourceEncryptionKey.__init__() missing 2 required keyword-only arguments: 'key_name' and 'vault_uri'

I also tried defining all of these parameters in encryptionKey , however I get the following warning and my original error of missing parameters:

WARNING - azure.search.documents.indexes._generated._serialization - keyVaultUri is not a known attribute of class <class 'azure.search.documents.indexes.models._models.SearchResourceEncryptionKey'> and will be ignored
azure.search.documents.indexes._generated._serialization - keyVaultKeyName is not a known attribute of class <class 'azure.search.documents.indexes.models._models.SearchResourceEncryptionKey'> and will be ignored

To Reproduce
Steps to reproduce the behaviour:

Assuming Blob Storage Account , Azure OpenAI Instance, Azure AI Search, Index and indexer all already exist and managed identity enabled with storage blob data read role (or necessary perms).

  1. Install the library azure-search-documents==11.6.0b5
  2. Define SearchResourceEncryptionKey object for encryption.
  3. Create Indexer client.
  4. Define skills, projection and skillset passing SearchResourceEncryptionKey object defined earlier.
  5. Attempt to create skillset for above indexer.
  6. Observe the "missing parameters" error.
from azure.search.documents.indexes import SearchIndexerClient
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes.models import (
    AzureOpenAIEmbeddingSkill,
    IndexProjectionMode,
    InputFieldMappingEntry,
    OutputFieldMappingEntry,
    SearchIndexer,
    SearchIndexerDataContainer,
    SearchIndexerDataSourceConnection,
    SearchIndexerIndexProjection,
    SearchIndexerIndexProjectionSelector,
    SearchIndexerIndexProjectionsParameters,
    SearchIndexerSkillset,
    SearchResourceEncryptionKey,
    SplitSkill,
)
# Initialize the client
indexer_client = SearchIndexerClient(endpoint="https://<your-search-service>.search.windows.net",
                             credential=AzureKeyCredential("<your-key>"))

# Define an encryption key
encryption_key_test = 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>",
)

# define skills, projection and skillset
split_skill = SplitSkill(
      description="Split skill to chunk documents",
      text_split_mode="pages",
      context="/document",
      maximum_page_length=2000,
      page_overlap_length=200,
      inputs=[
          InputFieldMappingEntry(name="text", source="/document/content"),
      ],
      outputs=[OutputFieldMappingEntry(name="textItems", target_name="pages")],
)

embedding_skill = AzureOpenAIEmbeddingSkill(
    description="Skill to generate embeddings via Azure OpenAI",
    context="/document/pages/*",
    resource_url="<azure_openai_url>", # resource uri for azure open ai instance
    deployment_name="<deployment-name>", # deployment name of embedding model deployed in azure open ai
    api_key="<azure_openai_key>", # key for azure open ai instance
    inputs=[
        InputFieldMappingEntry(name="text", source="/document/pages/*"),
    ],
    outputs=[OutputFieldMappingEntry(name="embedding", target_name="vectors")],
)

index_projection = SearchIndexerIndexProjection(
    selectors=[
        SearchIndexerIndexProjectionSelector(
            target_index_name="<index_name>",
            parent_key_field_name="parent_id",
            source_context="/document/pages/*",
            mappings=[
                InputFieldMappingEntry(name="content", source="/document/pages/*"),
                InputFieldMappingEntry(name="vector_embedding", source="/document/pages/*/vectors"),
            ],
        ),
    ],
    parameters=SearchIndexerIndexProjectionsParameters(
        projection_mode=IndexProjectionMode.SKIP_INDEXING_PARENT_DOCUMENTS
    ),
)

skillset = SearchIndexerSkillset(
        name="<skillset_name>",
        description="Skillset to chunk documents and generate embeddings",
        skills=[split_skill, embedding_skill],
        index_projection=index_projection,
        encryption_key=encryption_key_test,
)
            
# Attempt to create a skillset 
indexer_client.create_or_update_skillset(skillset)

Additional context
I use this encryption key in other places too i.e. when creating index, data source connection, indexer so it would be helpful if it can be checked this encryption key works for this version in the other places as i already found 1 bug while trying to create data source connection too. Thanks!

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Sep 23, 2024
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@YVass1
Copy link
Author

YVass1 commented Sep 23, 2024

I saw the same error when using encryption key with SearchIndexer

Here is the code snippet to add on

indexer = SearchIndexer(
      name="indexer-name-example",
      description="Indexer to index documents and generate embeddings",
      # TODO Bug in creating skillset so commented out for now 
      # skillset_name="<skillset-name>",
      target_index_name="<index-name>",
      data_source_name="<data-source-connection>",
      encryption_key=encryption_key_test,
      schedule=IndexingSchedule(
          interval="PT1H", start_time="2024-09-12T22:04:02Z"
      ),
  )
  
indexer_client.create_or_update_indexer(indexer)

@YVass1
Copy link
Author

YVass1 commented Sep 30, 2024

Hi, is there an update ? Is there a new package release with the fix included now ?

@xiangyan99
Copy link
Member

xiangyan99 commented Sep 30, 2024

The fix is merged. It will be available in next release in about 2 weeks.

@YVass1
Copy link
Author

YVass1 commented Oct 1, 2024

Thanks, will that be a beta release or it is possible to release the fix earlier in a beta release ?

@xiangyan99
Copy link
Member

That will be a beta release and if everything goes well, we will ship it on 8th.

@xiangyan99
Copy link
Member

FYI. azure-search-documents 11.6.0b6 is shipped. https://pypi.org/project/azure-search-documents/11.6.0b6/

@xiangyan99 xiangyan99 added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Oct 8, 2024
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Oct 8, 2024
Copy link

github-actions bot commented Oct 8, 2024

Hi @YVass1. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

Copy link

Hi @YVass1, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search
Projects
None yet
Development

No branches or pull requests

2 participants