diff --git a/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/README.md b/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/README.md index 0c01125e5cec..54518fa86d02 100644 --- a/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/README.md +++ b/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/README.md @@ -119,13 +119,17 @@ Lists all available analyzers in your Microsoft Foundry resource. Shows how to d ### Sample 08: Update Analyzer #### `sample_update_analyzer.py` / `sample_update_analyzer_async.py` -Updates an existing custom analyzer's description and tags. Shows how to modify analyzer properties. +Updates an existing custom analyzer's description and tags. Only `description` and `tags` can be updated +with `update_analyzer`. Use `begin_create_analyzer` with `allow_replace=True` to change create-only +properties such as `models`, `field_schema`, `config`, `dynamic_field_schema`, `processing_location`, or +`knowledge_sources`. If `base_analyzer_id` is included in an update request, it must match the existing +analyzer. **Key concepts:** - Updating analyzer description - Adding, updating, and removing tags - Verifying analyzer updates -- Modifying analyzer properties +- Replacing create-only analyzer properties with `begin_create_analyzer(..., allow_replace=True)` ### Sample 09: Delete Analyzer diff --git a/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/async_samples/sample_update_analyzer_async.py b/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/async_samples/sample_update_analyzer_async.py index 84fefbc0d401..9d866fe20cda 100644 --- a/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/async_samples/sample_update_analyzer_async.py +++ b/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/async_samples/sample_update_analyzer_async.py @@ -11,11 +11,15 @@ This sample demonstrates how to update an existing custom analyzer, including updating its description and tags. - The update_analyzer method allows you to modify certain properties of an existing analyzer. - The following properties can be updated: + The update_analyzer method allows you to modify only these properties of an existing analyzer: - Description: Update the analyzer's description - Tags: Add or update tags + To change create-only properties such as models, field_schema, config, + dynamic_field_schema, processing_location, or knowledge_sources, use begin_create_analyzer + with allow_replace=True. If base_analyzer_id is included in an update request, it must + match the existing analyzer. + USAGE: python sample_update_analyzer_async.py @@ -94,7 +98,9 @@ async def main() -> None: tags_str = ", ".join(f"{k}={v}" for k, v in current_analyzer.tags.items()) print(f" Tags: {tags_str}") - # Create an updated analyzer with new description and tags + # Create an updated analyzer with the properties supported by update_analyzer. + # Keep base_analyzer_id unchanged; other create-only properties require + # begin_create_analyzer(..., allow_replace=True). updated_analyzer = ContentAnalyzer( base_analyzer_id=current_analyzer.base_analyzer_id, description="Updated description", diff --git a/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/sample_update_analyzer.py b/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/sample_update_analyzer.py index 70b1410f419f..f72b89fe32a8 100644 --- a/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/sample_update_analyzer.py +++ b/sdk/contentunderstanding/azure-ai-contentunderstanding/samples/sample_update_analyzer.py @@ -11,11 +11,15 @@ This sample demonstrates how to update an existing custom analyzer, including updating its description and tags. - The update_analyzer method allows you to modify certain properties of an existing analyzer. - The following properties can be updated: + The update_analyzer method allows you to modify only these properties of an existing analyzer: - Description: Update the analyzer's description - Tags: Add or update tags + To change create-only properties such as models, field_schema, config, + dynamic_field_schema, processing_location, or knowledge_sources, use begin_create_analyzer + with allow_replace=True. If base_analyzer_id is included in an update request, it must + match the existing analyzer. + USAGE: python sample_update_analyzer.py @@ -92,7 +96,9 @@ def main() -> None: tags_str = ", ".join(f"{k}={v}" for k, v in current_analyzer.tags.items()) print(f" Tags: {tags_str}") - # Create an updated analyzer with new description and tags + # Create an updated analyzer with the properties supported by update_analyzer. + # Keep base_analyzer_id unchanged; other create-only properties require + # begin_create_analyzer(..., allow_replace=True). updated_analyzer = ContentAnalyzer( base_analyzer_id=current_analyzer.base_analyzer_id, description="Updated description", diff --git a/sdk/contentunderstanding/azure-ai-contentunderstanding/tests/conftest.py b/sdk/contentunderstanding/azure-ai-contentunderstanding/tests/conftest.py index 70599b28e003..194281c87674 100644 --- a/sdk/contentunderstanding/azure-ai-contentunderstanding/tests/conftest.py +++ b/sdk/contentunderstanding/azure-ai-contentunderstanding/tests/conftest.py @@ -111,6 +111,11 @@ def add_sanitizers(test_proxy): value="https://Sanitized.services.ai.azure.com", regex=r"https://[a-zA-Z0-9\-]+\.services\.ai\.azure\.com", ) + # Keep playback stable when recorded endpoints include a trailing slash. + add_uri_regex_sanitizer( + regex=r"//contentunderstanding", + value="/contentunderstanding", + ) # Sanitize Ocp-Apim-Subscription-Key header (where the API key is sent) add_header_regex_sanitizer(key="Ocp-Apim-Subscription-Key", value="fake-api-key", regex=".*")