# API tạo VM từ Template

## <mark style="color:green;">Tổng quan</mark>

* Trong tài liệu này, bạn sẽ tìm thấy thông tin chi tiết về cách chuẩn bị và tạo VM từ template
* API này tạo một VM với tên mặc định (tên VM của template), network mặc định "VM Network," và compute và storage mặc định

## <mark style="color:green;">Quy trình</mark>

{% stepper %}
{% step %}
**Bước 1: Thu thập thông tin**&#x20;

Đăng nhập vào **IAM portal** -> **vCD portal**: thu thập thông tin

**{{vcd\_url}}**

<figure><img src="/files/NrunUskW6Ker0Q6vn1Ju" alt=""><figcaption></figcaption></figure>

**{{vdc\_uuid}}:** Đăng nhập vào vCD portal -> chọn **VDC** -> xem và ghi lại **vdc\_uuid** trên URL

<figure><img src="/files/kWf2bjEbjbZT2hiIzzsk" alt=""><figcaption></figcaption></figure>

**{{network\_uuid}}:** Trên vCD portal -> Networking -> Networks -> New

{% hint style="warning" %}
**Lưu ý tên network phải là "VM Network"**
{% endhint %}

<figure><img src="/files/ay5jACUBKTSpUHcValRb" alt=""><figcaption></figcaption></figure>

Chọn “VM Network” -> và ghi lại thông tin network uuid trên url.

<figure><img src="/files/MhKdz1JZJJ3TGa9dmc4x" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/PSKF3J0MMdW3oZaQSDNN" alt=""><figcaption></figcaption></figure>

**{{vappTemplate\_uuid}}**: Trên vCD portal -> Content Hub -> Catalogs ->HIGIO Shared Catalogs

<figure><img src="/files/DfxzhfJpXjaUux0n3zGe" alt=""><figcaption></figcaption></figure>

-> vApp Templates -> Chọn template mà bạn muốn tạo VM -> ghi lại vappTemplate\_uuid trên url.

<figure><img src="/files/6gru1McK7jxsjXQGqU1M" alt=""><figcaption><p><br></p></figcaption></figure>

<figure><img src="/files/AHhzQiHuzwwQAbq15XYf" alt=""><figcaption></figcaption></figure>

**{{Bearer Token}}:** Làm theo hướng dẫn **“**[**Api đăng nhập băng token**](/hi-gio-user-guide-vn/compute/4.-hi-gio-api/api-dang-nhap-bang-token.md)**”** .

{% endstep %}

{% step %}
**Bước 2: Tạo VM từ template.**

**Postman:**

OST https\://{{vcd\_url}}/api/vdc

/{{vdc\_uuid}}/action/instantiateVAppTemplate

Authorization: {{Bearer Token }}

Headers:

\- 'Accept: \*/\*;version=37.2

\- ‘Content-type’: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml; charset=ISO-8859-1

<figure><img src="/files/yI6m4CEq93Ck29a6NzIK" alt=""><figcaption></figcaption></figure>

Body: {{Chọn Raw, Sao chép, Dán và Chỉnh sửa code bên dưới}}

```
<?xml version="1.0" encoding="UTF-8"?>

<vcloud:InstantiateVAppTemplateParams

    xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"

    xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"

    deploy="false"

    name="your vapp name"

    powerOn="false">

    <vcloud:Description>VApp Description</vcloud:Description>

    <vcloud:InstantiationParams>

        <vcloud:NetworkConfigSection>

            <ovf:Info>NetInfo</ovf:Info>

            <vcloud:NetworkConfig networkName="VM Network">

                <vcloud:Configuration>

                    <vcloud:ParentNetwork

                        href="https:// {{vcd_url}}/api/network/{{network_uuid}}"

                        name="VM Network"

                        type="application/vnd.vmware.vcloud.network+xml"/>

                    <vcloud:FenceMode>bridged</vcloud:FenceMode>

                </vcloud:Configuration>

            </vcloud:NetworkConfig>

        </vcloud:NetworkConfigSection>

    </vcloud:InstantiationParams>

    <vcloud:Source

        href="https://{{vcd_url}}/api/vAppTemplate/{{vappTemplate_uuid}}"

        name="HIGIO"

        type="application/vnd.vmware.vcloud.vAppTemplate+xml"/>

</vcloud:InstantiateVAppTemplateParams>
```

<figure><img src="/files/ARc14huRHfV2FN58NfV3" alt=""><figcaption></figcaption></figure>

**SEND request.**
{% endstep %}

{% step %}

### Bước 3: Kiểm tra

Trên vCD -> Data Center -> Chọn Virtual Data Center của bạn ->vApps -> Kiểm tra vApp và  VM của bạn.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.higiocloud.vn/hi-gio-user-guide-vn/compute/4.-hi-gio-api/api-tao-vm-tu-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
