作为云管理员,您可以在构建基础架构时利用 Microsoft Azure 插件置备基于插件的虚拟机。此外,还可以使用分配帮助程序为虚拟机提供分配逻辑。

可以使用最新的 Azure 属性轻松配置虚拟机以支持您的基础架构需求。例如,如果要为虚拟机启用引导诊断,可以在云模板中使用 boot_diagnostics 属性。

还可以对 Azure 虚拟机运行以下实施后操作:
  • 启动
  • 关闭电源
  • 重新启动
  • 取消分配
有关详细信息,请参见 可以对 Automation Assembler 部署或支持的资源运行哪些操作

要了解有关 VMware Aria Automation 中的插件和分配的更多信息,请参见 Automation Assembler 中基于插件的设计和部署

虚拟机属性

基于插件的 Azure 虚拟机需要以下属性。

属性 说明
name 资源的插件特定名称。

可以对 virtual_machine_name 属性使用相同的值。

virtual_machine_name Azure 门户中虚拟机的名称。

使用 Automation Assembler 部署的 Azure 资源必须符合 Azure 命名规则和限制。否则,部署将失败。有关详细信息,请参见资源命名限制

account 您的团队在其中部署云模板的帐户区域的 Microsoft Azure 云帐户。

有关详细信息,请参见VMware Aria Automation 中创建 Microsoft Azure 云帐户

location 将部署虚拟机的区域。
resource_group_name 资源组的名称。

必须在 Azure 门户中创建资源组。

置备具有数据磁盘的 Azure 虚拟机

以下模板展示了如何使用分配帮助程序置备虚拟机。在此示例中,将创建连接了数据磁盘的虚拟机。

在部署此模板之前,请完成以下步骤:

  1. Automation Assembler 中创建 Microsoft Azure 云帐户,创建项目,并添加云区域。
  2. 通过 Azure 门户创建资源组。
  3. 在 Azure 门户中的资源组中创建网络接口。网络接口必须位于将用于部署 Azure 虚拟机的区域。
formatVersion: 1
inputs:
  UUID:
    type: string
    title: UUID
resources:
  Allocations_Compute_1:
    type: Allocations.Compute
    properties: {}
  Allocations_Flavor_1:
    type: Allocations.Flavor
    properties:
      flavor: medium
  Allocations_Image_1:
    type: Allocations.Image
    properties:
      image: ubuntu
  Cloud_Azure_ResourceGroup_1:
    type: Cloud.Azure.ResourceGroup
    properties:
      name: e2e-a8n-RG-${input.UUID}
      useExisting: false
  Idem_NETWORK:
    type: Idem.AZURE.NETWORK.VIRTUAL_NETWORKS
    properties:
      name: e2e-a8n-idem-virtual-net-${input.UUID}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      location: ${resource.Allocations_Compute_1.selectedRegion.id}
      address_space:
        - 10.0.0.0/24
      subnets:
        - name: ${resource.Idem_NETWORK.name}
          address_prefix: 10.0.0.0/24
      resource_group_name: ${resource.Cloud_Azure_ResourceGroup_1.resourceName}
      virtual_network_name: ${resource.Idem_NETWORK.name}
  Idem_NETWORK_INTERFACE:
    type: Idem.AZURE.NETWORK.NETWORK_INTERFACES
    properties:
      name: e2e-a8n-idem-net-interface-${input.UUID}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      location: ${resource.Allocations_Compute_1.selectedRegion.id}
      ip_configurations:
        - primary: true
          name: ipconfig2
          private_ip_address: 10.0.0.13
          private_ip_address_allocation: Static
          private_ip_address_version: IPv4
          subnet_id: ${'/subscriptions/' + resource.Idem_NETWORK.subscription_id + '/resourceGroups/' + resource.Idem_NETWORK.resource_group_name + '/providers/Microsoft.Network/virtualNetworks/' + resource.Idem_NETWORK.name + '/subnets/' + resource.Idem_NETWORK.subnets[0].name}
      resource_group_name: ${resource.Idem_NETWORK.resource_group_name}
      network_interface_name: ${resource.Idem_NETWORK_INTERFACE.name}
  Idem_DATA_DISK:
    type: Idem.AZURE.COMPUTE.DISKS
    properties:
      name: e2e-a8n-idem-data-disk-${input.UUID}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      location: ${resource.Allocations_Compute_1.selectedRegion.id}
      resource_group_name: ${resource.Idem_NETWORK.resource_group_name}
      disk_name: ${resource.Idem_DATA_DISK.name}
      disk_size_gb: 10
      creation_data:
        create_option: Empty
      encryption:
        disk_encryption_set_id: ${'/subscriptions/' + resource.Idem_NETWORK.subscription_id + '/resourceGroups/DND-static-RG-for-automation/providers/Microsoft.Compute/diskEncryptionSets/DND-e2e-a8n-disk-encryption'}
        type: EncryptionAtRestWithCustomerKey
  Idem_VM:
    type: Idem.AZURE.COMPUTE.VIRTUAL_MACHINES
    properties:
      name: e2e-a8n-idem-vm-${input.UUID}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      location: ${resource.Allocations_Compute_1.selectedRegion.id}
      resource_group_name: ${resource.Idem_NETWORK.resource_group_name}
      virtual_machine_name: ${resource.Idem_VM.name}
      network_interface_ids:
        - ${resource.Idem_NETWORK_INTERFACE.resource_id}
      os_profile:
        admin_username: my-admin-username
        computer_name: machine-name
        admin_password: admin
      virtual_machine_size: ${resource.Allocations_Flavor_1.selectedInstanceTypeName}
      storage_image_reference:
        image_sku: ${split(resource.Allocations_Image_1.selectedImageId, ':')[2]}
        image_publisher: ${split(resource.Allocations_Image_1.selectedImageId, ':')[0]}
        image_version: ${split(resource.Allocations_Image_1.selectedImageId, ':')[3]}
        image_offer: ${split(resource.Allocations_Image_1.selectedImageId, ':')[1]}
      storage_os_disk:
        storage_account_type: Standard_LRS
        disk_name: e2e-a8n-idem-os-disk-${input.UUID}
        disk_caching: ReadWrite
        disk_size_in_GB: 30
        disk_create_option: FromImage
        disk_delete_option: Delete
      storage_data_disks:
        - disk_id: ${resource.Idem_DATA_DISK.resource_id}
          disk_logical_unit_number: 3
          disk_create_option: Attach
          disk_delete_option: Delete
          disk_size_in_GB: 10
          disk_name: ${resource.Idem_DATA_DISK.disk_name}
  Cloud_Service_Azure_SQL_Server_1:
    type: Cloud.Service.Azure.SQL.Server
    properties:
      name: e2e-a8n-db-server-puca-${input.UUID}
      region: ${resource.Allocations_Compute_1.selectedRegion.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      version: ''
      administrator_login: [email protected]
      resource_group_name: ${resource.Cloud_Azure_ResourceGroup_1.resourceName}
      administrator_login_password: admin
  Idem_AZURE_SQL_DATABASE_DATABASES_1:
    type: Idem.AZURE.SQL_DATABASE.DATABASES
    properties:
      name: e2e-a8n-idem-sql-db-${input.UUID}
      database_name: e2e-a8n-idem-sql-db-${input.UUID}
      server_name: ${resource.Cloud_Service_Azure_SQL_Server_1.name}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      location: ${resource.Allocations_Compute_1.selectedRegion.id}
      tags:
        tag-key: tag-value
      sku:
        name: GP_Gen5
        tier: GeneralPurpose
        family: Gen5
        capacity: 2
      requested_backup_storage_redundancy: Local
      resource_group_name: ${resource.Idem_NETWORK.resource_group_name}
      read_scale: Disabled
  Idem_AZURE_STORAGE_RESOURCE_PROVIDER_STORAGE_ACCOUNTS_1:
    type: Idem.AZURE.STORAGE_RESOURCE_PROVIDER.STORAGE_ACCOUNTS
    dependsOn:
      - Idem_NETWORK
    properties:
      name: e2ea8nidemstacct${input.UUID}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      location: ${resource.Allocations_Compute_1.selectedRegion.id}
      sku_name: Standard_LRS
      account_name: e2ea8nidemstacct${input.UUID}
      resource_group_name: ${resource.Cloud_Azure_ResourceGroup_1.resourceName}
      identity:
        type: UserAssigned
        user_assigned_identities:
          /subscriptions/svpvln45-brk0-mzca-7yxh-dla7h19zxyn3/resourceGroups/DND-static-RG-for-automation/providers/Microsoft.ManagedIdentity/userAssignedIdentities/DND-user-assigned-managed-identity: {}
      encryption_service:
        encryption_key_source: Microsoft.Keyvault
        blob_encryption_key_type: Account
        file_encryption_key_type: Account
      customer_managed_key:
        key_name: DND-e2e-a8n-key
        key_vault_uri: https://dnd-e2e-a8n-key-vault.vault.azure.net/
        key_version: ''
        user_assigned_identity_id: ${'/subscriptions/' + resource.Idem_NETWORK.subscription_id + '/resourceGroups/DND-static-RG-for-automation/providers/Microsoft.ManagedIdentity/userAssignedIdentities/DND-user-assigned-managed-identity'}
      immutability_policy:
        allow_protected_append_writes: true
        period_since_creation_in_days: 5
        state: Unlocked

如果要将其他磁盘连接到虚拟机,可以更新虚拟机资源的蓝图,并在 storage_data_disks 属性中添加新的数据磁盘。

使用 cloud-init 置备 Azure 虚拟机

以下模板展示了如何使用 cloud-init 置备 Azure 虚拟机。

首先,将 cloud-init 代码定义为云模板中的输入,并使用 custom_data 属性中的值。custom_data 属性仅接受 base64 编码的字符串,因此您可以使用 base64_encoded 函数转换自定义数据。

以下代码示例显示了如何将 cloud-init 代码定义为输入:
inputs:
  init-data:
    type: string
    default: |
      some
      multiline
      
    maxLength: 9999
以下代码示例显示了如何将自定义数据转换为 base64:
resources:
  Idem_AZURE_COMPUTE_VIRTUAL_MACHINES_1:
    type: Idem.AZURE.COMPUTE.VIRTUAL_MACHINES
    properties:
      ...
      os_profile:
        ...
        custom_data: ${base64_encode(input.init-data)}