{"id":1381,"library":"azure-mgmt-search","title":"Azure Search Management Client Library","description":"The `azure-mgmt-search` library provides a client for managing Azure AI Search (formerly Azure Cognitive Search) resources, including search services, private endpoint connections, and shared private link resources. It is part of the Azure SDK for Python, currently at version 9.2.0, and follows the Azure SDK's regular release cadence with updates typically released monthly or bi-monthly.","status":"active","version":"9.2.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/search/azure-mgmt-search","tags":["azure","search","management","sdk","cloud"],"install":[{"cmd":"pip install azure-mgmt-search azure-identity","lang":"bash","label":"Install with authentication dependency"}],"dependencies":[{"reason":"Required for `DefaultAzureCredential` based authentication, which is the recommended method for Azure SDKs.","package":"azure-identity"},{"reason":"Fundamental dependency for all Azure SDKs, providing shared primitives.","package":"azure-core","optional":true}],"imports":[{"symbol":"SearchManagementClient","correct":"from azure.mgmt.search import SearchManagementClient"},{"note":"Incorrectly importing from the data plane SDK (`azure-search-documents`) for management operations.","wrong":"from azure.search.documents import SearchClient","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.search import SearchManagementClient\n\n# Ensure these environment variables are set for DefaultAzureCredential\n# AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for service principal\n# Or AZURE_SUBSCRIPTION_ID and logged in via Azure CLI/VS Code\n\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"<your-subscription-id>\")\nresource_group_name = os.environ.get(\"AZURE_RESOURCE_GROUP_NAME\", \"<your-resource-group-name>\")\nsearch_service_name = os.environ.get(\"AZURE_SEARCH_SERVICE_NAME\", \"<your-search-service-name>\")\n\nif subscription_id == \"<your-subscription-id>\":\n    print(\"Please set the AZURE_SUBSCRIPTION_ID environment variable.\")\n    exit(1)\n\n# Authenticate using DefaultAzureCredential\ncredential = DefaultAzureCredential()\n\n# Create a SearchManagementClient\nclient = SearchManagementClient(credential, subscription_id)\n\ntry:\n    # Example 1: List all search services in the subscription\n    print(\"\\nListing all search services in subscription:\")\n    for service in client.services.list_by_subscription():\n        print(f\"  - {service.name} (Location: {service.location}, SKU: {service.sku.name})\")\n\n    # Example 2: List search services in a specific resource group\n    if resource_group_name != \"<your-resource-group-name>\":\n        print(f\"\\nListing search services in resource group '{resource_group_name}':\")\n        for service in client.services.list_by_resource_group(resource_group_name):\n            print(f\"  - {service.name} (Location: {service.location}, SKU: {service.sku.name})\")\n    else:\n        print(\"\\nTo list services by resource group, set AZURE_RESOURCE_GROUP_NAME.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and list Azure AI Search services within your subscription and a specific resource group using `SearchManagementClient`. It assumes you have the necessary environment variables set for authentication or are logged in via Azure CLI/VS Code."},"warnings":[{"fix":"Remove the `api_version` argument from the `SearchManagementClient` constructor. The SDK will use the appropriate API version.","message":"The `api_version` parameter is no longer directly passed to the `SearchManagementClient` constructor in version 9.x. The SDK now internally manages the API version corresponding to the client library version. Attempting to pass `api_version` will result in a `TypeError` or unexpected behavior.","severity":"breaking","affected_versions":"9.0.0 and above (breaking from 8.x)"},{"fix":"Always iterate directly over the returned paged object (e.g., `for service in client.services.list_by_subscription():`) or explicitly convert it to a list if all results are needed in memory (e.g., `list(client.services.list_by_subscription())`).","message":"List operations (e.g., `client.services.list_by_subscription()`) return a paged iterator (`ItemPaged`), not a Python list. You must iterate over the returned object to access all items. Directly indexing or assuming it's a complete list will lead to errors or only partial results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the `azure-identity` documentation for setting up `DefaultAzureCredential`. Ensure required environment variables are present or you are logged in through one of the supported development tools.","message":"Using `DefaultAzureCredential` requires proper environment variable configuration (e.g., `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` for service principal) or active login via Azure CLI (`az login`) or Visual Studio Code with the Azure Account extension. Failing to set this up correctly will result in authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the API reference for version 9.x to ensure correct property access and object construction. You may need to update your code to use the new property names or model structures.","message":"Between versions 8.x and 9.x, some model property names or structures within the management objects (e.g., for `SearchService`, `Sku`, `AdminKey`, `QueryKey`) have been updated or renamed to align with newer API versions or Azure naming conventions (e.g., Azure AI Search).","severity":"breaking","affected_versions":"9.0.0 and above (breaking from 8.x)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}