Azure AI Resources Package client library for Python¶
The Azure AI Resources package is part of the Azure AI SDK for Python and contains functionality for connecting to and managing your Azure AI resources and projects. Within your Azure AI projects it provides control plane operations for creating and managing data, indexes, models and deployments.
Source code | Package (PyPI) | API reference documentation | Product documentation | Samples
This package has been tested with Python 3.8, 3.9, 3.10, 3.11 and 3.12.
For a more complete set of Azure libraries, see https://aka.ms/azsdk/python/all.
Getting started¶
Prerequisites¶
Python 3.7 or later is required to use this package.
You must have an Azure subscription.
Install the package¶
Install the Azure AI generative package for Python with pip:
pip install azure-ai-resources
pip install azure-identity
Authenticate the client¶
from azure.ai.resources.client import AIClient
from azure.identity import DefaultAzureCredential
ai_client = AIClient(credential=DefaultAzureCredential(), subscription_id='subscription_id',
resource_group_name='resource_group', project_name='project_name')
Key concepts¶
Use this library within your Azure AI projects to provide control plane operations for creating and managing data, indexes, models and deployments.
Examples¶
View our samples repository on GitHub for examples demonstrating how to use the Azure AI Generative Python SDK.
Troubleshooting¶
General¶
Azure AI clients raise exceptions defined in Azure Core.
from azure.core.exceptions import HttpResponseError
try:
ai_client.compute.get("cpu-cluster")
except HttpResponseError as error:
print("Request failed: {}".format(error.message))
Logging¶
This library uses the standard logging library for logging. Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO level.
Detailed DEBUG level logging, including request/response bodies and unredacted headers, can be enabled on a client with the logging_enable
argument.
See full SDK logging documentation with examples here.
Telemetry¶
The Azure AI Generative Python SDK includes a telemetry feature that collects usage and failure data about the SDK and sends it to Microsoft when you use the SDK in a Jupyter Notebook only. Telemetry will not be collected for any use of the Python SDK outside of a Jupyter Notebook.
Telemetry data helps the SDK team understand how the SDK is used so it can be improved and the information about failures helps the team resolve problems and fix bugs. The SDK telemetry feature is enabled by default for Jupyter Notebook usage and cannot be enabled for non-Jupyter scenarios. To opt out of the telemetry feature in a Jupyter scenario, set the environment variable "AZURE_AI_RESOURCES_ENABLE_LOGGING"
to "False"
.
Next steps¶
View our samples repository on GitHub for examples demonstrating how to use the Azure AI Generative Python SDK.
Contributing¶
If you encounter any bugs or have suggestions, please file an issue in the Issues section of the project.
Indices and tables¶
Developer Documentation
- azure.ai.resources package
- Subpackages
- azure.ai.resources.client package
AIClient
AIClient.build_index_on_cloud()
AIClient.from_config()
AIClient.get_default_aoai_connection()
AIClient.get_default_content_safety_connection()
AIClient.ai_resource_name
AIClient.ai_resources
AIClient.azure_open_ai_deployments
AIClient.connections
AIClient.data
AIClient.indexes
AIClient.models
AIClient.project_name
AIClient.projects
AIClient.resource_group_name
AIClient.single_deployments
AIClient.subscription_id
AIClient.tracking_uri
- azure.ai.resources.constants package
- azure.ai.resources.entities package
AIResource
AIResource.container_registry
AIResource.customer_managed_key
AIResource.default_project_resource_group
AIResource.description
AIResource.display_name
AIResource.enable_data_isolation
AIResource.existing_workspaces
AIResource.id
AIResource.identity
AIResource.location
AIResource.managed_network
AIResource.name
AIResource.primary_user_assigned_identity
AIResource.public_network_access
AIResource.resource_group
AIResource.storage_account
AIResource.tags
ApiKeyConfiguration
AzureAISearchConnection
AzureAISearchConnection.set_current_environment()
AzureAISearchConnection.api_version
AzureAISearchConnection.credentials
AzureAISearchConnection.id
AzureAISearchConnection.is_shared
AzureAISearchConnection.metadata
AzureAISearchConnection.name
AzureAISearchConnection.tags
AzureAISearchConnection.target
AzureAISearchConnection.type
AzureAIServiceConnection
AzureAIServiceConnection.set_current_environment()
AzureAIServiceConnection.api_version
AzureAIServiceConnection.credentials
AzureAIServiceConnection.id
AzureAIServiceConnection.is_shared
AzureAIServiceConnection.kind
AzureAIServiceConnection.metadata
AzureAIServiceConnection.name
AzureAIServiceConnection.tags
AzureAIServiceConnection.target
AzureAIServiceConnection.type
AzureBlobStoreConnection
AzureBlobStoreConnection.set_current_environment()
AzureBlobStoreConnection.account_name
AzureBlobStoreConnection.container_name
AzureBlobStoreConnection.credentials
AzureBlobStoreConnection.id
AzureBlobStoreConnection.is_shared
AzureBlobStoreConnection.metadata
AzureBlobStoreConnection.name
AzureBlobStoreConnection.tags
AzureBlobStoreConnection.target
AzureBlobStoreConnection.type
AzureOpenAIConnection
AzureOpenAIConnection.set_current_environment()
AzureOpenAIConnection.api_type
AzureOpenAIConnection.api_version
AzureOpenAIConnection.credentials
AzureOpenAIConnection.id
AzureOpenAIConnection.is_shared
AzureOpenAIConnection.metadata
AzureOpenAIConnection.name
AzureOpenAIConnection.tags
AzureOpenAIConnection.target
AzureOpenAIConnection.type
AzureOpenAIDeployment
AzureOpenAIDeploymentProperties
AzureOpenAIModel
AzureOpenAIModelConfiguration
AzureOpenAISku
BaseConnection
CustomConnection
Data
GitHubConnection
Index
Project
SystemData
- Submodules
- azure.ai.resources.entities.ai_resource module
- azure.ai.resources.entities.base_connection module
- azure.ai.resources.entities.configs module
- azure.ai.resources.entities.connection_subtypes module
- azure.ai.resources.entities.data module
- azure.ai.resources.entities.deployment_keys module
- azure.ai.resources.entities.mlindex module
- azure.ai.resources.entities.models module
- azure.ai.resources.entities.project module
- azure.ai.resources.entities.single_deployment module
- azure.ai.resources.operations package
- azure.ai.resources.client package
- Subpackages