Install & Compatibility
Where this runs
tested against v9.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.616s · 44.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.9s · import 0.556s · 45MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SearchManagementClient
✓ from azure.mgmt.search import SearchManagementClient
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
✗ from azure.search.documents import SearchClient
Incorrectly importing from the data plane SDK (`azure-search-documents`) for management operations.
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.
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.search import SearchManagementClient
# Ensure these environment variables are set for DefaultAzureCredential
# AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for service principal
# Or AZURE_SUBSCRIPTION_ID and logged in via Azure CLI/VS Code
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "<your-subscription-id>")
resource_group_name = os.environ.get("AZURE_RESOURCE_GROUP_NAME", "<your-resource-group-name>")
search_service_name = os.environ.get("AZURE_SEARCH_SERVICE_NAME", "<your-search-service-name>")
if subscription_id == "<your-subscription-id>":
print("Please set the AZURE_SUBSCRIPTION_ID environment variable.")
exit(1)
# Authenticate using DefaultAzureCredential
credential = DefaultAzureCredential()
# Create a SearchManagementClient
client = SearchManagementClient(credential, subscription_id)
try:
# Example 1: List all search services in the subscription
print("\nListing all search services in subscription:")
for service in client.services.list_by_subscription():
print(f" - {service.name} (Location: {service.location}, SKU: {service.sku.name})")
# Example 2: List search services in a specific resource group
if resource_group_name != "<your-resource-group-name>":
print(f"\nListing search services in resource group '{resource_group_name}':")
for service in client.services.list_by_resource_group(resource_group_name):
print(f" - {service.name} (Location: {service.location}, SKU: {service.sku.name})")
else:
print("\nTo list services by resource group, set AZURE_RESOURCE_GROUP_NAME.")
except Exception as e:
print(f"An error occurred: {e}")
Debug
Known issues
breakingThe `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.fixRemove the `api_version` argument from the `SearchManagementClient` constructor. The SDK will use the appropriate API version.
affects: 9.0.0 and above (breaking from 8.x)
gotchaList 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.fixAlways 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())`).
affects: All versions
gotchaUsing `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.fixRefer 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.
affects: All versions
breakingBetween 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).fixConsult 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.
affects: 9.0.0 and above (breaking from 8.x)
gotchaMany Azure management clients require a subscription ID to identify the target subscription for operations. This can be provided via the `AZURE_SUBSCRIPTION_ID` environment variable or passed directly to the client constructor. Failing to provide it will result in errors such as 'Please set the AZURE_SUBSCRIPTION_ID environment variable.'fixSet the `AZURE_SUBSCRIPTION_ID` environment variable, or pass the subscription ID as an argument to the management client constructor (e.g., `SearchManagementClient(credential, subscription_id=...)`).
affects: All versions
Upgrade
Version history
9.2.0latest on PyPI · released Jul 21, 2025
Audit
Dependencies
azure-identityrequiredRequired for `DefaultAzureCredential` based authentication, which is the recommended method for Azure SDKs.
azure-coreoptionalFundamental dependency for all Azure SDKs, providing shared primitives.