将资源组克隆到另一个

问题描述 投票:0回答:1

在 Azure 中是否可以将一组资源克隆到另一组资源中?

我尝试在天蓝色中使用“导出模板”来实现此目的,但是当我部署此模板时,某些资源未加载,我无法弄清楚原因。还有其他方法可以做到这一点吗?比如说通过蔚蓝云壳之类的东西? fail deploy

azure azure-devops resources clone
1个回答
0
投票

它很可能会失败,因为参数在 Azure 中必须是唯一的,例如公共 IP 或应用程序服务完全限定域的 DNS 标签,因此您需要更改这些(这可能是一项巨大的工作,具体取决于有多少资源你有)

我找到了一些替代方案,老实说我还没有测试过,但它们看起来很有希望

  1. RG复制

RGCOPY (Resource Group COPY) is a tool that copies the most important resources of an Azure resource group (source RG) to a new resource group (target RG). It can copy a whole landscape consisting of many servers within a single Azure resource group to a new resource group.

并且它支持以下资源

  • Microsoft.Compute/虚拟机
  • Microsoft.Compute/磁盘
  • Microsoft.网络/虚拟网络
  • Microsoft.网络/网络安全组
  • Microsoft.网络/网络接口
  • Microsoft.Network/publicIPAddresses
  • Microsoft.Network/publicIPPrefixes
  • Microsoft.Network/loadBalancers
  • Microsoft.Network/natGateways
  • Microsoft.Compute/availabilitySets
  • Microsoft.Compute/proximityPlacementGroups
  • Microsoft.Compute/virtualMachineScaleSets
  • Microsoft.Network/bastionHosts

源资源 RG 中的所有其他资源都将被跳过,不会复制到目标 RG

  1. 导出-AzResourceGroup

The Export-AzResourceGroup cmdlet captures the specified resource group as a template and saves it to a JSON file.This can be useful in scenarios where you have already created some resources in your resource group, and then want to leverage the benefits of using template backed deployments.

This cmdlet gives you an easy start by generating the template for your existing resources in the resource group. There might be some cases where this cmdlet fails to generate some parts of the template. Warning messages will inform you of the resources that failed. The template will still be generated for the parts that were successful

这与您使用的导出模板类似,但有一些限制

导出不保证成功。导出并不是将现有资源转变为可在生产中使用的模板的可靠方法。

从资源组或资源导出时,导出的模板是根据每种资源类型的已发布架构生成的。有时,架构没有资源类型的最新版本。检查导出的模板以确保它包含您需要的属性。如有必要,编辑导出的模板以使用您需要的 API 版本。

  1. 使用 AzureRM 复制/克隆脚本(不完全确定这是否有效)

复制资源组

can be done, but it requires considerable time and effort to manually recreate the network resources, copy the virtual hard disks and attach to newly created virtual machines. To eliminate the manual effort I created a Powershell script

这是他的存储库https://github.com/JeffBow/AzurePowerShell,你会找到两个脚本来尝试一下

参考资料:

© www.soinside.com 2019 - 2024. All rights reserved.