Azure Common
The `azure-common` library served as a foundational package providing shared code, common exceptions, and configuration mechanisms across various older Azure SDK for Python libraries. While its latest release is 1.1.28 (February 2022), much of its functionality has been superseded by `azure-core` and `azure-identity` in the newer generation of Azure SDKs. It generally had a slow release cadence due to its foundational nature.
Warnings
- breaking The `azure-common` library is officially deprecated, and its support ended on March 31, 2023. It is strongly recommended to migrate to the newer Azure SDK client libraries which utilize `azure-core` and `azure-identity` for common functionalities, as older libraries will no longer receive official support and updates from Microsoft.
- gotcha `azure-common` has implicit, undeclared dependencies on `msrest`, `msrestazure`, and `adal` for certain (now mostly deprecated) functionalities, such as `azure.common.client_factory`. Without these packages explicitly installed, attempting to use such features will result in `ImportError`s. Both `msrestazure` and `adal` are themselves deprecated.
- deprecated Specific methods within `azure-common`, such as `azure.common.cloud.get_cli_active_cloud` and `azure.common.credentials.get_azure_cli_credentials`, are deprecated (explicitly in version 1.1.28) and are incompatible with `azure-cli-core` versions 2.21.0 and higher due to API changes in the CLI.
Install
-
pip install azure-common
Imports
- AzureMissingResourceOrPropertyError
from azure.common import AzureMissingResourceOrPropertyError
- get_azure_cli_credentials
from azure.common.credentials import get_azure_cli_credentials
Quickstart
from azure.common import AzureMissingResourceOrPropertyError
try:
raise AzureMissingResourceOrPropertyError('Resource not found in legacy system.')
except AzureMissingResourceOrPropertyError as e:
print(f"Caught expected legacy error: {e}")
# For new code, consider using azure-core exceptions, e.g.:
# from azure.core.exceptions import ResourceNotFoundError
# try:
# raise ResourceNotFoundError('Resource not found in modern system.')
# except ResourceNotFoundError as e:
# print(f"Caught modern error: {e}")