Azure Management SAP Hana on Azure
The `azure-mgmt-hanaonazure` library is the Microsoft Azure SAP Hana on Azure Management Client Library for Python. Its current stable version is 1.0.0, released in April 2021. This library is part of the older generation of Azure SDKs and has been officially deprecated, with support for the underlying older SDK guidelines ending. Developers are advised to migrate to the newer Azure SDK management libraries for continued support and updates.
Warnings
- breaking This library (`azure-mgmt-hanaonazure`) is officially deprecated. Microsoft recommends migrating to newer Azure SDK management libraries for ongoing support, security updates, and new features.
- breaking The credential system was completely revamped. `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported. Use `azure-identity` classes (e.g., `DefaultAzureCredential`). The `credentials` parameter has been renamed to `credential`.
- breaking Operations that previously returned `msrest.polling.LROPoller` now return `azure.core.polling.LROPoller` and are prefixed with `begin_` (e.g., `create_or_update` becomes `begin_create_or_update`).
- breaking The `HanaManagementClient` class cannot be imported from `azure.mgmt.hanaonazure.hana_management_client`. It must be imported directly from the package root: `from azure.mgmt.hanaonazure import HanaManagementClient`.
- breaking The `config` attribute no longer exists on client objects. Configuration should be passed as keyword arguments during client instantiation (e.g., `MyClient(credential, subscription_id, enable_logging=True)`).
- breaking The exception hierarchy has been simplified. Most exceptions are now `azure.core.exceptions.HttpResponseError`. `CloudError` has been removed.
- gotcha The `azure-mgmt-hanaonazure` package was explicitly tested only up to Python 3.8. Using it with newer Python versions (e.g., 3.9+) might encounter unexpected compatibility issues, although it may still function.
Install
-
pip install azure-mgmt-hanaonazure azure-identity
Imports
- HanaManagementClient
from azure.mgmt.hanaonazure import HanaManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.hanaonazure import HanaManagementClient
# Set your Azure Subscription ID as an environment variable or replace directly
SUBSCRIPTION_ID = os.environ.get("AZURE_SUBSCRIPTION_ID", "your-subscription-id")
if SUBSCRIPTION_ID == "your-subscription-id":
print("Please set the AZURE_SUBSCRIPTION_ID environment variable or replace 'your-subscription-id'.")
exit(1)
# Authenticate with Azure. DefaultAzureCredential attempts several common authentication methods.
credential = DefaultAzureCredential()
# Create a client for SAP Hana on Azure Management
client = HanaManagementClient(credential, SUBSCRIPTION_ID)
print(f"Listing SAP HANA on Azure operations for subscription: {SUBSCRIPTION_ID}")
# Example: List available operations (a common pattern for management clients)
# Note: Specific resource listing methods may vary, this is a generic example.
# If there are no specific 'list' methods on the client root, one might need to access
# sub-clients like client.operations.list() or client.hana_instances.list()
try:
# Assuming there's a list method for operations or a top-level resource.
# The exact method will depend on the API definition for HanaOnAzure.
# For demonstration, we'll try a common pattern. If it fails, actual usage
# requires consulting the specific service's API reference.
# As per docs, 'operations' is a common attribute for listing supported ops.
for operation in client.operations.list():
print(f"Operation: {operation.name} - {operation.display.provider}/{operation.display.resource}/{operation.display.operation}")
except AttributeError:
print("Client does not have a 'operations.list()' method. Please consult the API reference for available resource management methods, e.g., for listing HANA instances.")
except Exception as e:
print(f"An error occurred: {e}")