Replace deprecated Azure meta-package with specific Azure packages#513
Conversation
Co-authored-by: ogajduse <20440883+ogajduse@users.noreply.github.com>
ogajduse
left a comment
There was a problem hiding this comment.
One of the checks is failing with the following.
wrapanapi/systems/__init__.py:5: in <module>
from .msazure import AzureSystem
wrapanapi/systems/msazure.py:11: in <module>
from azure.common.credentials import ServicePrincipalCredentials
/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/azure/common/credentials.py:162: in <module>
raise ImportError("You need to install 'msrest' to use this feature")
E ImportError: You need to install 'msrest' to use this feature
I have found that the azure-common package was redesigned and azure-identity should be used instead. See https://stackoverflow.com/questions/64063850/azure-python-sdk-serviceprincipalcredentials-object-has-no-attribute-get-tok for more information about how to change ServicePrincipalCredentials with ClientSecretCredential.
…ncipalCredentials Co-authored-by: ogajduse <20440883+ogajduse@users.noreply.github.com>
Fixed in commit d5fd214. Replaced the deprecated |
ogajduse
left a comment
There was a problem hiding this comment.
The current version actually still requires msrestazure library as we import from azure.common.exceptions import CloudError. However, as it internally uses msrestazure, the import could be changed to from msrestazure.azure_exceptions import CloudError
ImportError: cannot import name 'BlockBlobService' from 'azure.storage.blob' (/home/ogajduse/.virtualenvs/wrapanapi-tester/lib/python3.13/site-packages/azure/storage/blob/__init__.py)
Could be also seen in https://github.com/RedHatQE/wrapanapi/actions/runs/16298976783/job/46099664030?pr=513
The BlockBlobService was migrated to other classes. See the following migration doc to see how the migration should be done.
https://github.com/Azure/azure-sdk-for-python/blob/9d3f4aaf3125cc6ae63c8425d0d15d20d488d61e/sdk/storage/azure-storage-blob/migration_guide.md
List of methods from BlockBlobService that are used in wrapanapi:
container_client.make_blob_url(
container_client.copy_blob(
self.container_client.delete_container(
container_client.list_containers(
container_client.account_name
container_client.delete_blob(
container_client.list_blobs(
make_blob_url(
get_blob_properties(
Once the following import is changed, the requirement on azure-common could be removed from the project.
from azure.common import AzureConflictHttpError to from azure.core.exceptions import HttpResponseError
…Client - Replace deprecated CloudError from azure.common with msrestazure.azure_exceptions.CloudError - Replace deprecated AzureConflictHttpError with azure.core.exceptions.HttpResponseError - Migrate BlockBlobService to BlobServiceClient following Azure SDK migration guide - Update all blob operations to use new client structure: * make_blob_url() -> get_blob_client().url * copy_blob() -> start_copy_from_url() * delete_blob() -> get_blob_client().delete_blob() * list_blobs() -> get_container_client().list_blobs() * get_blob_properties() -> get_blob_client().get_blob_properties() - Update dependencies: remove azure-common, add azure-core and msrestazure - Fix blob property access for lease state checking Co-authored-by: ogajduse <20440883+ogajduse@users.noreply.github.com>
Fixed in commit 9938eb8. I've migrated away from the deprecated Azure APIs as suggested:
This should resolve both the |
|
I have tested this patch with robottelo. All Azure-related tests passed. Switching it to ready-to-review. |
The
azure==4.0.0meta-package has been deprecated since v5.0.0 and causes installation failures with the error:This PR replaces the deprecated meta-package with the specific Azure packages required by the codebase.
Changes Made
Removed:
azure==4.0.0(deprecated meta-package)azure-storage-common>=1.0Added 7 specific Azure packages:
azure-common(forazure.commonimports)azure-mgmt-compute(forazure.mgmt.computeimports)azure-mgmt-iothub(forazure.mgmt.iothubimports)azure-mgmt-network(forazure.mgmt.networkimports)azure-mgmt-resource(forazure.mgmt.resourceimports)azure-mgmt-storage(forazure.mgmt.storageimports)azure-storage-blob(forazure.storage.blobimports)Benefits
✅ Resolves installation failures - No more deprecated meta-package errors
✅ Latest versions - All packages unpinned to get most recent compatible releases
✅ Minimal footprint - Only installs the specific Azure packages actually used
✅ Future-proof - Follows Azure SDK for Python migration guidelines
✅ No breaking changes - All existing imports in
msazure.pyremain functionalValidation
wrapanapi/systems/msazure.pyare covered by the new dependenciesThis change enables successful installation of wrapanapi and aligns with the Azure SDK migration recommendations.
Fixes #512.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.