【Azure Compute Gallery】使用 Python 代码从 Azure Compute Gallery 复制 Image-Version
问题描述
Azure Compute Gallery 可以帮助围绕 Azure 资源(例如映像和应用程序)生成结构和组织,并且支持全局复制。

如果想通过Python代码实现 Image-Version从一个Azure Compute Gallery复制到另一个中,如何实现呢?
问题解答
示例Python代码:
import os
from msrestazure.azure_cloud import AZURE_CHINA_CLOUD as CLOUD
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.compute.models import GalleryImageVersion, GalleryImageVersionStorageProfile, GalleryImageVersionPublishingProfile, GalleryArtifactVersionSource, TargetRegion credential = DefaultAzureCredential(authority=CLOUD.endpoints.active_directory)
SUBSCRIPTION_ID = "{subscriptionId}" client = ComputeManagementClient(credential, subscription_id=SUBSCRIPTION_ID,
base_url = CLOUD.endpoints.resource_manager,
credential_scopes = [CLOUD.endpoints.resource_manager + "/.default"]
) //设置源 Image Version的Resource ID ...
source = GalleryArtifactVersionSource(id=" /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}")
storageprofile = GalleryImageVersionStorageProfile(source=source)
//设置目标region
targetregion = TargetRegion(name="{region}")
publishingprofile = GalleryImageVersionPublishingProfile(target_regions=[targetregion], replica_count=1, exclude_from_latest=True) imageversion = GalleryImageVersion(location="{region}", publishing_profile=publishingprofile, storage_profile=storageprofile) image_creation = client.gallery_image_versions.begin_create_or_update(resource_group_name
="{resourceGroup}", gallery_name="{galleryName}", gallery_image_name="{imageDefinitionName}", gallery_image_version_name="{versionName}", gallery_image_version=imageversion)
// 创建目标 Image Version
image_creation.wait()
注意: {subscriptionId} , {galleryName},{resourceGroup},{region},{imageDefinitionName},{versionName} 均需要替换为对应的真实值。
参考资料
Python对Gallery Images Version操作的Python class GalleryImageVersionsOperations : https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2021_07_01.operations.galleryimageversionsoperations?view=azure-python
使用ComputeManagementClient class的gallery_image_version属性来初始化 : https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2021_07_01.computemanagementclient?view=azure-python
/END/
【Azure Compute Gallery】使用 Python 代码从 Azure Compute Gallery 复制 Image-Version的更多相关文章
- 【Azure 环境】【Azure Developer】使用Python代码获取Azure 中的资源的Metrics定义及数据
问题描述 使用Python SDK来获取Azure上的各种资源的Metrics的名称以及Metrics Data的示例 问题解答 通过 azure-monitor-query ,可以创建一个 metr ...
- 【Azure Redis 缓存】使用Python代码获取Azure Redis的监控指标值 (含Powershell脚本方式)
问题描述 通过Metrics监控页面,我们能得知当前资源(如Redis)的运行情况与各种指标.如果我们需要把指标下载到本地或者生成JSON数据导入到第三方的监控平台呢?Azure是否可以通过Pytho ...
- 【Azure Developer】使用 Python SDK连接Azure Storage Account, 计算Blob大小代码示例
问题描述 在微软云环境中,使用python SDK连接存储账号(Storage Account)需要计算Blob大小?虽然Azure提供了一个专用工具Azure Storage Explorer可以统 ...
- 【Azure Developer】使用Java代码启动Azure VM(虚拟机)
问题描述 在使用Java的启动Azure VM的过程中,遇见了com.azure.core.management.exception.ManagementException: Status code ...
- 【Azure Developer】【Python 】使用 azure.identity 和 azure.common.credentials 获取Azure AD的Access Token的两种方式
问题描述 使用Python代码,展示如何从Azure AD 中获取目标资源的 Access Token. 如要了解如何从AAD中获取 client id,client secret,tenant id ...
- 【Azure Developer】Python代码通过AAD认证访问微软Azure密钥保管库(Azure Key Vault)中机密信息(Secret)
关键字说明 什么是 Azure Active Directory?Azure Active Directory(Azure AD, AAD) 是 Microsoft 的基于云的标识和访问管理服务,可帮 ...
- 【Azure 存储服务】Python模块(azure.cosmosdb.table)直接对表存储(Storage Account Table)做操作示例
什么是表存储 Azure 表存储是一项用于在云中存储结构化 NoSQL 数据的服务,通过无结构化的设计提供键/属性存储. 因为表存储无固定的数据结构要求,因此可以很容易地随着应用程序需求的发展使数据适 ...
- 【Azure Developer】使用Java SDK代码创建Azure VM (包含设置NSG,及添加数据磁盘SSD)
在参考Azure官方文档进行VM创建时,发现其中没有包含如何设置NSG的内容,以及如何在创建时就添加数据磁盘的代码(设置磁盘为SSD类型).本文的内容以"使用 Java 创建和管理 Azur ...
- 【Azure Redis 缓存】 Python连接Azure Redis, 使用redis.ConnectionPool 出现 "ConnectionResetError: [Errno 104] Connection reset by peer"
问题描述 Python连接Azure Redis, 使用redis.ConnectionPool 出现 "ConnectionResetError: [Errno 104] Connecti ...
- 【Azure 存储服务】代码版 Azure Storage Blob 生成 SAS (Shared Access Signature: 共享访问签名)
问题描述 在使用Azure存储服务,为了有效的保护Storage的Access Keys.可以使用另一种授权方式访问资源(Shared Access Signature: 共享访问签名), 它的好处可 ...
随机推荐
- [转帖]kubelet 原理解析三:runtime
本文转自:https://feisky.xyz/posts/kube... 架构 Kubelet 架构图 Generic Runtime Manager:这是容器运行时的管理者,负责于 CRI 交互, ...
- [转帖] mysql的timestamp会存在时区问题?
我感觉 这样理解也有点不对 timestamp 应该是不带时区 只是 UTC1970-1-1 的时间戳 但是展示时会根据时区做一下计算 date time 就不会做转换而已. 原创:打码日记(微信 ...
- TienChin 运行 RuoYi-Vue3
在前几篇文章当中,之前使用的是 Vue2,在某一天发现若依提供了 Vue3 的版本,所以这篇文章主要是运行起来,Vue2,迟早要被替代,所以这里采用最先进的 Vue3. 仓库地址:https://gi ...
- net8来了
11 月 15 日开始的为期三天的 .NET Conf 在线活动的开幕日上,.NET 8作为微软的开源跨平台开发平台正式发布..NET 团队着重强调云.性能.全栈 Blazor.AI 和 .NET M ...
- Paddlenlp之UIE关系抽取模型【高管关系抽取为例】
往期项目回顾: Paddlenlp之UIE模型实战实体抽取任务[打车数据.快递单] Paddlenlp之UIE分类模型[以情感倾向分析新闻分类为例]含智能标注方案) 应用实践:分类模型大集成者[Pad ...
- C/C++ BeaEngine 反汇编引擎
反汇编引擎有很多,这个引擎没有Dll,是纯静态链接库,适合r3-r0环境,你可以将其编译为DLL文件,驱动强制注入到游戏进程中,让其快速反汇编,读取出反汇编代码并保存为txt文本,本地分析. 地址:h ...
- a标签download属性跨域问题
1.如果是加载了非同源的内容,该属性将失效,等于导航功能 2.在服务端设置Content-Disposition,使用HTTP响应头Content-disposition进行处理 3.先下载数据文件, ...
- 散片便宜300元!但还是劝你买盒装CPU
喜欢DIY的小伙伴在选购产品时会纠结于散片和盒装,以13代酷睿i5-13600KF为例,散片一般是1899元左右,而盒装2199元,两者相差300元,AMD的锐龙5 7600也差不多,盒装和散片相差也 ...
- 小结_第一个Java程序
总结: 1. Java程序的编写与执行: 步骤1: 编写. 在后缀名为.java的文件中编写Java代码,该文件称为源文件 步骤2: 编译. 针对后缀名为.java源文件进行编译,生成字节码文件. 格 ...
- python高级用法之命名元组namedtuple
1.tuple类型数据的获取 大家都知道,元组里面的数据获取只能通过下标的方式去获取,比如 :a = ('username', 'age', 'phone'),要获取username的话 ,就需要用a ...