跳转到主要内容

Microsoft Azure Image Builder Python客户端库

项目描述

Microsoft Azure SDK for Python

这是Microsoft Azure Image Builder客户端库。此软件包已在Python 3.8+上进行了测试。要查看Azure库的更完整视图,请参阅azure sdk python发布

免责声明

Azure SDK Python软件包对Python 2.7的支持已于2022年1月1日结束。有关更多信息和建议,请参阅https://github.com/Azure/azure-sdk-for-python/issues/20691

入门

先决条件

安装软件包

pip install azure-mgmt-imagebuilder
pip install azure-identity

身份验证

默认情况下,Azure Active Directory 令牌身份验证依赖于以下环境变量的正确配置。

  • AZURE_CLIENT_ID 用于 Azure 客户端 ID。
  • AZURE_TENANT_ID 用于 Azure 租户 ID。
  • AZURE_CLIENT_SECRET 用于 Azure 客户端密钥。

此外,可以通过环境变量 AZURE_SUBSCRIPTION_ID 配置 Azure 订阅 ID。

以上配置后,客户端可以通过以下代码进行认证

from azure.identity import DefaultAzureCredential
from azure.mgmt.imagebuilder import ImageBuilderClient
import os

sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
client = ImageBuilderClient(credential=DefaultAzureCredential(), subscription_id=sub_id)

示例

此包的代码示例可以在

故障排除

下一步

提供反馈

如果您遇到任何错误或建议,请在项目的 问题 部分提交问题。

发行历史

1.4.0 (2024-06-17)

新增功能

  • ImageTemplate 模型具有新参数 auto_run
  • ImageTemplate 模型具有新参数 managed_resource_tags
  • ImageTemplateUpdateParametersProperties 模型具有新参数 vm_profile
  • VirtualNetworkConfig 模型具有新参数 container_instance_subnet_id

1.3.0 (2023-12-18)

新增功能

  • ImageTemplate 模型具有新参数 error_handling
  • ImageTemplateUpdateParameters 模型具有新参数 properties

1.2.0 (2023-04-20)

新增功能

  • 添加了 TriggersOperations 操作组
  • ImageTemplate 模型具有新参数 optimize
  • ImageTemplateSharedImageDistributor 模型具有新参数 target_regions
  • ImageTemplateSharedImageDistributor 模型具有新参数 versioning
  • ImageTemplateSharedImageVersionSource 模型具有新参数 exact_version
  • ImageTemplateVhdDistributor 模型具有新参数 uri

1.2.0b1 (2022-11-28)

其他更改

  • 在 GitHub 仓库中添加了生成的示例
  • 停止支持 python<3.7.0

1.1.0 (2022-06-07)

功能

  • ImageTemplate 模型具有新参数 exact_staging_resource_group
  • ImageTemplate 模型具有新参数 staging_resource_group
  • ImageTemplate 模型具有新参数 validate
  • Resource 模型具有新参数 system_data
  • RunOutput 模型具有新参数 system_data
  • TrackedResource 模型具有新参数 system_data

1.0.0 (2021-12-07)

功能

  • ImageTemplate 模型具有新参数 system_data
  • VirtualNetworkConfig 模型具有新参数 proxy_vm_size
  • ImageTemplateVmProfile 模型具有新参数 user_assigned_identities
  • ImageTemplatePlatformImageSource 模型具有新参数 exact_version

破坏性更改

  • Resource 模型不再有 tags 参数
  • Resource 模型不再有 location 参数

1.0.0b1 (2021-05-25)

这是测试预览版本。

此版本使用下一代代码生成器,引入了重要的破坏性更改,但也引入了重要的新功能(如统一身份验证和异步编程)。

一般破坏性更改

  • 凭证系统已被完全重做

    • azure.common.credentialsmsrestazure.azure_active_directory 实例不再受支持,请使用 azure-identity 类:[https://pypi.ac.cn/project/azure-identity/](https://pypi.ac.cn/project/azure-identity/)
    • credentials 参数已重命名为 credential
  • 客户端上的 config 属性不再存在,配置应作为 kwarg 传递。例如:MyClient(credential, subscription_id, enable_logging=True)。有关支持选项的完整集合,请参阅 [azure-core 初始化文档中的参数接受](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)

  • 您不能再导入 version 模块了,请使用 __version__ 代替

  • 以前返回 msrest.polling.LROPoller 的操作现在返回 azure.core.polling.LROPoller,并带有 begin_ 前缀。

  • 异常树已简化,大多数异常现在为 azure.core.exceptions.HttpResponseError(《CloudError》已删除)。

  • 大多数操作 kwarg 已更改。以下是一些最明显的更改

    • raw 已移除。可以通过使用 cls 找到等效功能,cls 是一个回调,它将为高级用户提供对内部 HTTP 响应的访问
    • 有关支持选项的完整集合,请参阅 azure-core 的 请求参数文档

通用新功能

  • 支持使用 typing 进行类型注解。SDKs 已准备好使用 mypy。
  • 此客户端现在提供稳定和官方的异步支持。检查您包中的 aio 命名空间以找到异步客户端。
  • 此客户端现在原生支持 OpenCensus 或 OpenTelemetry 等跟踪库。请参阅此 跟踪快速入门 以获取概述。

0.4.0 (2020-05-07)

功能

  • 模型操作有新的参数 is_data_action
  • 模型 ImageTemplateSharedImageDistributor 有新的参数 exclude_from_latest
  • 模型 ImageTemplateSharedImageDistributor 有新的参数 storage_account_type
  • 模型 ImageTemplatePlatformImageSource 有新的参数 plan_info
  • 模型 ImageTemplateVmProfile 有新的参数 vnet_config
  • 模型 ImageTemplateVmProfile 有新的参数 os_disk_size_gb
  • 添加了操作 VirtualMachineImageTemplatesOperations.cancel

破坏性更改

  • 模型 ImageTemplate 的 identity 参数现在是必需的

0.3.0 (2019-11-19)

功能

  • 模型 ImageTemplatePowerShellCustomizer 有新的参数 run_elevated
  • 模型 ImageTemplatePowerShellCustomizer 有新的参数 sha256_checksum
  • 模型 ImageTemplate 有新的参数 vm_profile
  • 模型 ImageTemplateFileCustomizer 有新的参数 sha256_checksum
  • 模型 ImageTemplateShellCustomizer 有新的参数 sha256_checksum

一般破坏性更改

此版本使用下一代代码生成器,它可能会在从某些导入中引入破坏性更改。总之,一些模块被错误地可见/可导入,并且已被重命名。这修复了由于使用最初不应使用的类而引起的一些问题。

  • 无法从 azure.mgmt.imagebuilder.image_builder_client 导入 ImageBuilderClient(从 azure.mgmt.imagebuilder 的导入与之前一样工作)
  • ImageBuilderClientConfiguration 的导入已从 azure.mgmt.imagebuilder.image_builder_client 移动到 azure.mgmt.imagebuilder
  • 无法使用 azure.mgmt.imagebuilder.models.my_class 从 "models" 子模块导入模型 MyClass(从 azure.mgmt.imagebuilder.models 的导入与之前一样工作)
  • 无法使用 azure.mgmt.imagebuilder.operations.my_class_operationsoperations 子模块导入操作类 MyClassOperations(从 azure.mgmt.imagebuilder.operations 的导入与之前一样工作)

最后但并非最不重要的是,HTTP 连接池现在默认启用。您应始终将客户端用作上下文管理器,或调用 close(),或每个进程最多使用一个客户端。

0.2.1 (2019-04-25)

错误修复

  • 添加缺少的 build_timeout_in_minutes
  • 修复一些正则表达式检查

0.2.0 (2019-04-12)

  • 新 API 版本 2019-05-01-preview

0.1.0 (2019-04-09)

  • 初始发布

由以下支持