Повторное создание образа (обновление операционной системы) виртуальной машины, на которой нет временного диска ОС, для виртуальных машин с временным диском ОС, для которых виртуальная машина сбрасывается в исходное состояние. ПРИМЕЧАНИЕ. Сохранение старого диска ОС зависит от значения deleteOption диска ОС. Если параметр deleteOption отключен, старый диск ОС будет сохранен после повторного образа. Если параметр deleteOption имеет значение delete, старый диск ОС будет удален после повторного воспроизведения образа. Перед выполнением повторного образа необходимо соответствующим образом обновить deleteOption диска ОС.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage?api-version=2024-03-01
Параметры URI
Имя |
В |
Обязательно |
Тип |
Описание |
resourceGroupName
|
path |
True
|
string
|
Имя группы ресурсов.
|
subscriptionId
|
path |
True
|
string
|
Учетные данные подписки, которые однозначно идентифицируют подписку Microsoft Azure. Идентификатор подписки формирует часть URI для каждого вызова службы.
|
vmName
|
path |
True
|
string
|
Имя виртуальной машины.
|
api-version
|
query |
True
|
string
|
Версия API клиента.
|
Текст запроса
Ответы
Имя |
Тип |
Описание |
200 OK
|
|
ОК
|
202 Accepted
|
|
Принято
|
Other Status Codes
|
CloudError
|
Ответ об ошибке, описывающий причину сбоя операции.
|
Безопасность
azure_auth
Поток OAuth2 в Azure Active Directory
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Имя |
Описание |
user_impersonation
|
олицетворения учетной записи пользователя
|
Примеры
Reimage a Non-Ephemeral Virtual Machine.
Sample Request
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVMName/reimage?api-version=2024-03-01
{
"tempDisk": true,
"exactVersion": "aaaaaa",
"osProfile": {
"adminPassword": "{your-password}",
"customData": "{your-custom-data}"
}
}
import com.azure.resourcemanager.compute.models.OSProfileProvisioningData;
import com.azure.resourcemanager.compute.models.VirtualMachineReimageParameters;
/**
* Samples for VirtualMachines Reimage.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/
* virtualMachineExamples/VirtualMachine_Reimage_NonEphemeralVMs.json
*/
/**
* Sample code: Reimage a Non-Ephemeral Virtual Machine.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void reimageANonEphemeralVirtualMachine(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachines().reimage(
"myResourceGroup", "myVMName", new VirtualMachineReimageParameters().withTempDisk(true)
.withExactVersion("aaaaaa").withOsProfile(new OSProfileProvisioningData()
.withAdminPassword("fakeTokenPlaceholder").withCustomData("{your-custom-data}")),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_reimage_non_ephemeral_vms.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
client.virtual_machines.begin_reimage(
resource_group_name="myResourceGroup",
vm_name="myVMName",
).result()
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/virtualMachineExamples/VirtualMachine_Reimage_NonEphemeralVMs.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/92de53a5f1e0e03c94b40475d2135d97148ed014/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/virtualMachineExamples/VirtualMachine_Reimage_NonEphemeralVMs.json
func ExampleVirtualMachinesClient_BeginReimage_reimageANonEphemeralVirtualMachine() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachinesClient().BeginReimage(ctx, "myResourceGroup", "myVMName", &armcompute.VirtualMachinesClientBeginReimageOptions{Parameters: &armcompute.VirtualMachineReimageParameters{
ExactVersion: to.Ptr("aaaaaa"),
OSProfile: &armcompute.OSProfileProvisioningData{
AdminPassword: to.Ptr("{your-password}"),
CustomData: to.Ptr("{your-custom-data}"),
},
TempDisk: to.Ptr(true),
},
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before performing the reimage.
*
* @summary Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before performing the reimage.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/virtualMachineExamples/VirtualMachine_Reimage_NonEphemeralVMs.json
*/
async function reimageANonEphemeralVirtualMachine() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmName = "myVMName";
const parameters = {
exactVersion: "aaaaaa",
osProfile: {
adminPassword: "{your-password}",
customData: "{your-custom-data}",
},
tempDisk: true,
};
const options = { parameters };
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachines.beginReimageAndWait(
resourceGroupName,
vmName,
options,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
Location: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/westus/operations/{operationId}&monitor=true&api-version=2024-03-01
Reimage a Virtual Machine.
Sample Request
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVMName/reimage?api-version=2024-03-01
{
"tempDisk": true
}
import com.azure.resourcemanager.compute.models.VirtualMachineReimageParameters;
/**
* Samples for VirtualMachines Reimage.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/
* virtualMachineExamples/VirtualMachine_Reimage.json
*/
/**
* Sample code: Reimage a Virtual Machine.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void reimageAVirtualMachine(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachines().reimage("myResourceGroup", "myVMName",
new VirtualMachineReimageParameters().withTempDisk(true), com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_reimage.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
client.virtual_machines.begin_reimage(
resource_group_name="myResourceGroup",
vm_name="myVMName",
).result()
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/virtualMachineExamples/VirtualMachine_Reimage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/92de53a5f1e0e03c94b40475d2135d97148ed014/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/virtualMachineExamples/VirtualMachine_Reimage.json
func ExampleVirtualMachinesClient_BeginReimage_reimageAVirtualMachine() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachinesClient().BeginReimage(ctx, "myResourceGroup", "myVMName", &armcompute.VirtualMachinesClientBeginReimageOptions{Parameters: &armcompute.VirtualMachineReimageParameters{
TempDisk: to.Ptr(true),
},
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before performing the reimage.
*
* @summary Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before performing the reimage.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/virtualMachineExamples/VirtualMachine_Reimage.json
*/
async function reimageAVirtualMachine() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmName = "myVMName";
const parameters = { tempDisk: true };
const options = { parameters };
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachines.beginReimageAndWait(
resourceGroupName,
vmName,
options,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
Location: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/westus/operations/{operationId}&monitor=true&api-version=2024-03-01
Определения
ApiError
Ошибка API.
Имя |
Тип |
Описание |
code
|
string
|
Код ошибки.
|
details
|
ApiErrorBase[]
|
Сведения об ошибке API
|
innererror
|
InnerError
|
Внутренняя ошибка API
|
message
|
string
|
Сообщение об ошибке.
|
target
|
string
|
Целевой объект конкретной ошибки.
|
ApiErrorBase
База ошибок API.
Имя |
Тип |
Описание |
code
|
string
|
Код ошибки.
|
message
|
string
|
Сообщение об ошибке.
|
target
|
string
|
Целевой объект конкретной ошибки.
|
CloudError
Ответ об ошибке от службы вычислений.
Имя |
Тип |
Описание |
error
|
ApiError
|
Ошибка API.
|
InnerError
Сведения о внутренней ошибке.
Имя |
Тип |
Описание |
errordetail
|
string
|
Внутреннее сообщение об ошибке или дамп исключений.
|
exceptiontype
|
string
|
Тип исключения.
|
OSProfileProvisioningData
Указывает сведения, необходимые для повторного создания образа неэфемерного диска ОС.
Имя |
Тип |
Описание |
adminPassword
|
string
|
Указывает пароль учетной записи администратора.
Минимальная длина (Windows): 8 символов
Минимальная длина (Linux): 6 символов
Максимальная длина (Windows): 123 символа
Максимальная длина (Linux): 72 символа
Требования к сложности: 3 из 4 условий, приведенных ниже, должны быть выполнены Содержит более низкие символы Содержит верхние символы Имеет цифру Имеет специальный символ (соответствие регулярных выражений [\W_])
Запрещенные значения: "abc@123", "P@$$w 0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!"
Сведения о сбросе пароля см. в статье Как сбросить службу удаленного рабочего стола или ее пароль для входа на виртуальной машине Windows.
Сведения о сбросе корневого пароля см. в статье Управление пользователями, SSH и проверка или восстановление дисков на виртуальных машинах Linux в Azure с помощью расширения VMAccess.
|
customData
|
string
|
Указывает строку пользовательских данных в кодировке base-64. Строка в кодировке base-64 кодируется в двоичный массив, который сохраняется в виде файла на виртуальной машине. Максимальная длина двоичного массива — 65 535 байт. Примечание. Не передайте секреты или пароли в свойстве customData. Это свойство не может быть обновлено после создания виртуальной машины. Свойство customData передается виртуальной машине для сохранения в виде файла. Дополнительные сведения см. в статье Пользовательские данные на виртуальных машинах Azure. При использовании cloud-init для виртуальной машины Linux см. статью Использование cloud-init для настройки виртуальной машины Linux во время создания.
|
VirtualMachineReimageParameters
Параметры, предоставленные для операции повторного создания образа виртуальной машины.
Имя |
Тип |
Описание |
exactVersion
|
string
|
Указывает в десятичном разряде версию диска ОС, в который необходимо переимыслить. Если точная версия не указана, диск ОПЕРАЦИОННОй системы будет переосмыслен на существующую версию диска ОС.
|
osProfile
|
OSProfileProvisioningData
|
Указывает сведения, необходимые для повторного создания образа неэфемерного диска ОС.
|
tempDisk
|
boolean
|
Указывает, следует ли повторно создавать временный диск. Значение по умолчанию: false. Примечание. Этот параметр повторного создания образа временного диска поддерживается только для виртуальных машин или VMSS с временным диском ОС.
|