Crie ou atualize uma versão de imagem da galeria.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}?api-version=2024-03-03
Parâmetros de URI
Nome |
Em |
Obrigatório |
Tipo |
Description |
galleryImageName
|
path |
True
|
string
|
O nome da definição de imagem da galeria na qual a Versão da Imagem deve ser criada.
|
galleryImageVersionName
|
path |
True
|
string
|
O nome da versão da imagem da galeria a ser criada. Precisa seguir o padrão de nome de versão semântica: os caracteres permitidos são dígito e ponto. Os dígitos devem estar dentro do intervalo de um inteiro de 32 bits. Formato:..
|
galleryName
|
path |
True
|
string
|
O nome da Galeria de Imagens Compartilhadas na qual reside a Definição de Imagem.
|
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos.
|
subscriptionId
|
path |
True
|
string
|
Credenciais de assinatura que identificam exclusivamente a assinatura do Microsoft Azure. A ID da assinatura faz parte do URI para cada chamada de serviço.
|
api-version
|
query |
True
|
string
|
Versão da API do cliente.
|
Corpo da solicitação
Nome |
Obrigatório |
Tipo |
Description |
location
|
True
|
string
|
Local do recurso
|
properties.storageProfile
|
True
|
GalleryImageVersionStorageProfile
|
Esse é o perfil de armazenamento de uma Versão de Imagem da Galeria.
|
properties.publishingProfile
|
|
GalleryImageVersionPublishingProfile
|
O perfil de publicação de uma versão de imagem da galeria.
|
properties.restore
|
|
boolean
|
Indica se essa é uma solicitação de restauração de recursos de exclusão reversível.
|
properties.safetyProfile
|
|
GalleryImageVersionSafetyProfile
|
Esse é o perfil de segurança da Versão da Imagem da Galeria.
|
properties.securityProfile
|
|
ImageVersionSecurityProfile
|
O perfil de segurança de uma versão de imagem da galeria
|
tags
|
|
object
|
Marcas de recurso
|
Respostas
Segurança
azure_auth
Fluxo OAuth2 do Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
Nome |
Description |
user_impersonation
|
representar sua conta de usuário
|
Exemplos
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"source": {
"communityGalleryImageId": "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithCommunityImageVersionAsSource.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using community gallery image as source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingCommunityGalleryImageAsSource(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(new GalleryImageVersionStorageProfile()
.withSource(new GalleryArtifactVersionFullSource().withCommunityGalleryImageId(
"/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}")))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithCommunityImageVersionAsSource.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingCommunityGalleryImageAsSource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
CommunityGalleryImageID: to.Ptr("/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// CommunityGalleryImageID: to.Ptr("/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithCommunityImageVersionAsSource.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingCommunityGalleryImageAsSource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
source: {
communityGalleryImageId:
"/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithCommunityImageVersionAsSource.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
CommunityGalleryImageId = "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}",
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"communityGalleryImageId": "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"communityGalleryImageId": "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"communityGalleryImageId": "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using managed image as source.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using managed image as source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingManagedImageAsSource(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(
new GalleryImageVersionStorageProfile().withSource(new GalleryArtifactVersionFullSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingManagedImageAsSource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingManagedImageAsSource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup//providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup//providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using mix of disks and snapshots as a source.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryDataDiskImage;
import com.azure.resourcemanager.compute.models.GalleryDiskImageSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.GalleryOSDiskImage;
import com.azure.resourcemanager.compute.models.HostCaching;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithSnapshotsAsSource.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using snapshots as a source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingSnapshotsAsASource(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(new GalleryImageVersionStorageProfile().withOsDiskImage(new GalleryOSDiskImage()
.withHostCaching(HostCaching.READ_ONLY)
.withSource(new GalleryDiskImageSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}")))
.withDataDiskImages(Arrays.asList(new GalleryDataDiskImage().withHostCaching(HostCaching.NONE)
.withSource(new GalleryDiskImageSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"))
.withLun(1))))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingMixOfDisksAndSnapshotsAsASource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
DataDiskImages: []*armcompute.GalleryDataDiskImage{
{
HostCaching: to.Ptr(armcompute.HostCachingNone),
Source: &armcompute.GalleryDiskImageSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"),
},
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.GalleryOSDiskImage{
HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
Source: &armcompute.GalleryDiskImageSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Source: &armcompute.GalleryDiskImageSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"),
// },
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// Source: &armcompute.GalleryDiskImageSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"),
// },
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingSnapshotsAsASource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
dataDiskImages: [
{
hostCaching: "None",
lun: 1,
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}",
},
},
],
osDiskImage: {
hostCaching: "ReadOnly",
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
OSDiskImage = new GalleryOSDiskImage
{
HostCaching = HostCaching.ReadOnly,
GallerySource = new GalleryDiskImageSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"),
},
},
DataDiskImages = {new GalleryDataDiskImage(1)
{
HostCaching = HostCaching.None,
GallerySource = new GalleryDiskImageSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"),
},
}},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using shallow replication mode.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"excludeFromLatest": false
}
],
"replicationMode": "Shallow"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.ReplicationMode;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithShallowReplicationMode.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using shallow replication mode.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingShallowReplicationMode(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions()
.createOrUpdate("myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US")
.withPublishingProfile(new GalleryImageVersionPublishingProfile()
.withTargetRegions(Arrays.asList(new TargetRegion().withName("West US")
.withRegionalReplicaCount(1).withExcludeFromLatest(false)))
.withReplicationMode(ReplicationMode.SHALLOW))
.withStorageProfile(new GalleryImageVersionStorageProfile()
.withSource(new GalleryArtifactVersionFullSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
.withSafetyProfile(new GalleryImageVersionSafetyProfile()
.withAllowDeletionOfReplicatedLocations(false).withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithShallowReplicationMode.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingShallowReplicationMode() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
ReplicationMode: to.Ptr(armcompute.ReplicationModeShallow),
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// ReplicationMode: to.Ptr(armcompute.ReplicationModeShallow),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithShallowReplicationMode.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingShallowReplicationMode() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
replicationMode: "Shallow",
targetRegions: [{ name: "West US", excludeFromLatest: false, regionalReplicaCount: 1 }],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithShallowReplicationMode.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
IsExcludedFromLatest = false,
}},
ReplicationMode = GalleryReplicationMode.Shallow,
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS",
"replicationMode": "Shallow"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS",
"replicationMode": "Shallow"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS",
"replicationMode": "Shallow"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using shared image as source.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithImageVersionAsSource.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using shared image as source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingSharedImageAsSource(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(
new GalleryImageVersionStorageProfile().withSource(new GalleryArtifactVersionFullSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}")))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithImageVersionAsSource.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingSharedImageAsSource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithImageVersionAsSource.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingSharedImageAsSource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithImageVersionAsSource.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"),
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using snapshots as a source.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryDataDiskImage;
import com.azure.resourcemanager.compute.models.GalleryDiskImageSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.GalleryOSDiskImage;
import com.azure.resourcemanager.compute.models.HostCaching;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithSnapshotsAsSource.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using snapshots as a source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingSnapshotsAsASource(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(new GalleryImageVersionStorageProfile().withOsDiskImage(new GalleryOSDiskImage()
.withHostCaching(HostCaching.READ_ONLY)
.withSource(new GalleryDiskImageSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}")))
.withDataDiskImages(Arrays.asList(new GalleryDataDiskImage().withHostCaching(HostCaching.NONE)
.withSource(new GalleryDiskImageSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"))
.withLun(1))))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingMixOfDisksAndSnapshotsAsASource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
DataDiskImages: []*armcompute.GalleryDataDiskImage{
{
HostCaching: to.Ptr(armcompute.HostCachingNone),
Source: &armcompute.GalleryDiskImageSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"),
},
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.GalleryOSDiskImage{
HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
Source: &armcompute.GalleryDiskImageSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Source: &armcompute.GalleryDiskImageSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"),
// },
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// Source: &armcompute.GalleryDiskImageSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"),
// },
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingSnapshotsAsASource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
dataDiskImages: [
{
hostCaching: "None",
lun: 1,
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}",
},
},
],
osDiskImage: {
hostCaching: "ReadOnly",
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
OSDiskImage = new GalleryOSDiskImage
{
HostCaching = HostCaching.ReadOnly,
GallerySource = new GalleryDiskImageSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"),
},
},
DataDiskImages = {new GalleryDataDiskImage(1)
{
HostCaching = HostCaching.None,
GallerySource = new GalleryDiskImageSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"),
},
}},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"
},
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"
},
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using vhd as a source with custom UEFI keys.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet",
"lun": 1
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
]
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
},
"securityProfile": {
"uefiSettings": {
"signatureTemplateNames": [
"MicrosoftUefiCertificateAuthorityTemplate"
],
"additionalSignatures": {
"kek": [
{
"type": "sha256",
"value": [
"<sha256 value>"
]
}
],
"db": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
],
"dbx": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
]
}
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryDataDiskImage;
import com.azure.resourcemanager.compute.models.GalleryDiskImageSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionUefiSettings;
import com.azure.resourcemanager.compute.models.GalleryOSDiskImage;
import com.azure.resourcemanager.compute.models.HostCaching;
import com.azure.resourcemanager.compute.models.ImageVersionSecurityProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import com.azure.resourcemanager.compute.models.UefiKey;
import com.azure.resourcemanager.compute.models.UefiKeySignatures;
import com.azure.resourcemanager.compute.models.UefiKeyType;
import com.azure.resourcemanager.compute.models.UefiSignatureTemplateName;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithVHD_UefiSettings.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using vhd as a source with custom UEFI keys.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingVhdAsASourceWithCustomUEFIKeys(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS).withExcludeFromLatest(false))))
.withStorageProfile(new GalleryImageVersionStorageProfile().withOsDiskImage(new GalleryOSDiskImage()
.withHostCaching(HostCaching.READ_ONLY)
.withSource(new GalleryDiskImageSource().withUri(
"https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd")
.withStorageAccountId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}")))
.withDataDiskImages(Arrays.asList(new GalleryDataDiskImage().withHostCaching(HostCaching.NONE)
.withSource(new GalleryDiskImageSource().withUri(
"https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd")
.withStorageAccountId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"))
.withLun(1))))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false))
.withSecurityProfile(
new ImageVersionSecurityProfile().withUefiSettings(new GalleryImageVersionUefiSettings()
.withSignatureTemplateNames(
Arrays.asList(UefiSignatureTemplateName.MICROSOFT_UEFI_CERTIFICATE_AUTHORITY_TEMPLATE))
.withAdditionalSignatures(new UefiKeySignatures()
.withKek(Arrays.asList(
new UefiKey().withType(UefiKeyType.SHA256).withValue(Arrays.asList("<sha256 value>"))))
.withDb(Arrays.asList(
new UefiKey().withType(UefiKeyType.X509).withValue(Arrays.asList("<x509 value>"))))
.withDbx(Arrays.asList(
new UefiKey().withType(UefiKeyType.X509).withValue(Arrays.asList("<x509 value>"))))))),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD_UefiSettings.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingVhdAsASourceWithCustomUefiKeys() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
SecurityProfile: &armcompute.ImageVersionSecurityProfile{
UefiSettings: &armcompute.GalleryImageVersionUefiSettings{
AdditionalSignatures: &armcompute.UefiKeySignatures{
Db: []*armcompute.UefiKey{
{
Type: to.Ptr(armcompute.UefiKeyTypeX509),
Value: []*string{
to.Ptr("<x509 value>")},
}},
Dbx: []*armcompute.UefiKey{
{
Type: to.Ptr(armcompute.UefiKeyTypeX509),
Value: []*string{
to.Ptr("<x509 value>")},
}},
Kek: []*armcompute.UefiKey{
{
Type: to.Ptr(armcompute.UefiKeyTypeSHA256),
Value: []*string{
to.Ptr("<sha256 value>")},
}},
},
SignatureTemplateNames: []*armcompute.UefiSignatureTemplateName{
to.Ptr(armcompute.UefiSignatureTemplateNameMicrosoftUefiCertificateAuthorityTemplate)},
},
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
DataDiskImages: []*armcompute.GalleryDataDiskImage{
{
HostCaching: to.Ptr(armcompute.HostCachingNone),
Source: &armcompute.GalleryDiskImageSource{
StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
},
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.GalleryOSDiskImage{
HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
Source: &armcompute.GalleryDiskImageSource{
StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// SecurityProfile: &armcompute.ImageVersionSecurityProfile{
// UefiSettings: &armcompute.GalleryImageVersionUefiSettings{
// AdditionalSignatures: &armcompute.UefiKeySignatures{
// Db: []*armcompute.UefiKey{
// {
// Type: to.Ptr(armcompute.UefiKeyTypeX509),
// Value: []*string{
// to.Ptr("<x509 value>")},
// }},
// Dbx: []*armcompute.UefiKey{
// {
// Type: to.Ptr(armcompute.UefiKeyTypeX509),
// Value: []*string{
// to.Ptr("<x509 value>")},
// }},
// Kek: []*armcompute.UefiKey{
// {
// Type: to.Ptr(armcompute.UefiKeyTypeSHA256),
// Value: []*string{
// to.Ptr("<sha256 value>")},
// }},
// },
// SignatureTemplateNames: []*armcompute.UefiSignatureTemplateName{
// to.Ptr(armcompute.UefiSignatureTemplateNameMicrosoftUefiCertificateAuthorityTemplate)},
// },
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// Source: &armcompute.GalleryDiskImageSource{
// StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
// URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
// },
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// Source: &armcompute.GalleryDiskImageSource{
// StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
// URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
// },
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD_UefiSettings.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingVhdAsASourceWithCustomUefiKeys() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
securityProfile: {
uefiSettings: {
additionalSignatures: {
db: [{ type: "x509", value: ["<x509 value>"] }],
dbx: [{ type: "x509", value: ["<x509 value>"] }],
kek: [{ type: "sha256", value: ["<sha256 value>"] }],
},
signatureTemplateNames: ["MicrosoftUefiCertificateAuthorityTemplate"],
},
},
storageProfile: {
dataDiskImages: [
{
hostCaching: "None",
lun: 1,
source: {
storageAccountId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
uri: "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd",
},
},
],
osDiskImage: {
hostCaching: "ReadOnly",
source: {
storageAccountId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
uri: "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD_UefiSettings.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
OSDiskImage = new GalleryOSDiskImage
{
HostCaching = HostCaching.ReadOnly,
GallerySource = new GalleryDiskImageSource
{
Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
},
},
DataDiskImages = {new GalleryDataDiskImage(1)
{
HostCaching = HostCaching.None,
GallerySource = new GalleryDiskImageSource
{
Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
},
}},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
SecurityUefiSettings = new GalleryImageVersionUefiSettings
{
SignatureTemplateNames = { UefiSignatureTemplateName.MicrosoftUefiCertificateAuthorityTemplate },
AdditionalSignatures = new UefiKeySignatures
{
Kek = {new UefiKey
{
KeyType = UefiKeyType.Sha256,
Value = {"<sha256 value>"},
}},
Db = {new UefiKey
{
KeyType = UefiKeyType.X509,
Value = {"<x509 value>"},
}},
Dbx = {new UefiKey
{
KeyType = UefiKeyType.X509,
Value = {"<x509 value>"},
}},
},
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"securityProfile": {
"uefiSettings": {
"signatureTemplateNames": [
"MicrosoftUefiCertificateAuthorityTemplate"
],
"additionalSignatures": {
"kek": [
{
"type": "sha256",
"value": [
"<sha256 value>"
]
}
],
"db": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
],
"dbx": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
]
}
}
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"securityProfile": {
"uefiSettings": {
"signatureTemplateNames": [
"MicrosoftUefiCertificateAuthorityTemplate"
],
"additionalSignatures": {
"kek": [
{
"type": "sha256",
"value": [
"<sha256 value>"
]
}
],
"db": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
],
"dbx": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
]
}
}
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"securityProfile": {
"uefiSettings": {
"signatureTemplateNames": [
"MicrosoftUefiCertificateAuthorityTemplate"
],
"additionalSignatures": {
"kek": [
{
"type": "sha256",
"value": [
"<sha256 value>"
]
}
],
"db": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
],
"dbx": [
{
"type": "x509",
"value": [
"<x509 value>"
]
}
]
}
}
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using vhd as a source.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet",
"lun": 1
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
]
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryDataDiskImage;
import com.azure.resourcemanager.compute.models.GalleryDiskImageSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.GalleryOSDiskImage;
import com.azure.resourcemanager.compute.models.HostCaching;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithVHD.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using vhd as a source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionUsingVhdAsASource(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS).withExcludeFromLatest(false))))
.withStorageProfile(new GalleryImageVersionStorageProfile().withOsDiskImage(new GalleryOSDiskImage()
.withHostCaching(HostCaching.READ_ONLY)
.withSource(new GalleryDiskImageSource().withUri(
"https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd")
.withStorageAccountId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}")))
.withDataDiskImages(Arrays.asList(new GalleryDataDiskImage().withHostCaching(HostCaching.NONE)
.withSource(new GalleryDiskImageSource().withUri(
"https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd")
.withStorageAccountId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"))
.withLun(1))))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingVhdAsASource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
DataDiskImages: []*armcompute.GalleryDataDiskImage{
{
HostCaching: to.Ptr(armcompute.HostCachingNone),
Source: &armcompute.GalleryDiskImageSource{
StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
},
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.GalleryOSDiskImage{
HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
Source: &armcompute.GalleryDiskImageSource{
StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// Source: &armcompute.GalleryDiskImageSource{
// StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
// URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
// },
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// Source: &armcompute.GalleryDiskImageSource{
// StorageAccountID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
// URI: to.Ptr("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
// },
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingVhdAsASource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
dataDiskImages: [
{
hostCaching: "None",
lun: 1,
source: {
storageAccountId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
uri: "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd",
},
},
],
osDiskImage: {
hostCaching: "ReadOnly",
source: {
storageAccountId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
uri: "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
OSDiskImage = new GalleryOSDiskImage
{
HostCaching = HostCaching.ReadOnly,
GallerySource = new GalleryDiskImageSource
{
Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
},
},
DataDiskImages = {new GalleryDataDiskImage(1)
{
HostCaching = HostCaching.None,
GallerySource = new GalleryDiskImageSource
{
Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"),
StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"),
},
}},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"osDiskImage": {
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"source": {
"storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
"uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"
},
"lun": 1,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using VM as source.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 2,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"source": {
"virtualMachineId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithVmAsSource.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version using VM as source.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateASimpleGalleryImageVersionUsingVMAsSource(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
2)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(new GalleryImageVersionStorageProfile()
.withSource(new GalleryArtifactVersionFullSource().withVirtualMachineId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}")))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVmAsSource.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionUsingVmAsSource() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
VirtualMachineID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// VirtualMachineID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVmAsSource.json
*/
async function createOrUpdateASimpleGalleryImageVersionUsingVMAsSource() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
source: {
virtualMachineId:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVmAsSource.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 2,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
VirtualMachineId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"),
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"virtualMachineId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"virtualMachineId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"virtualMachineId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version with Direct Drive replicas
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"additionalReplicaSets": [
{
"storageAccountType": "PreviumV2_LRS",
"regionalReplicaCount": 1
}
],
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.AdditionalReplicaSet;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithAdditionalReplicaSets.json
*/
/**
* Sample code: Create or update a simple Gallery Image Version with Direct Drive replicas.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionWithDirectDriveReplicas(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false)
.withAdditionalReplicaSets(Arrays.asList(new AdditionalReplicaSet()
.withStorageAccountType(StorageAccountType.fromString("PreviumV2_LRS"))
.withRegionalReplicaCount(1))),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(
new GalleryImageVersionStorageProfile().withSource(new GalleryArtifactVersionFullSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
.withSafetyProfile(
new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithAdditionalReplicaSets.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionWithDirectDriveReplicas() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
AdditionalReplicaSets: []*armcompute.AdditionalReplicaSet{
{
RegionalReplicaCount: to.Ptr[int32](1),
StorageAccountType: to.Ptr(armcompute.StorageAccountType("PreviumV2_LRS")),
}},
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// AdditionalReplicaSets: []*armcompute.AdditionalReplicaSet{
// {
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountType("PreviumV2_LRS")),
// }},
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithAdditionalReplicaSets.json
*/
async function createOrUpdateASimpleGalleryImageVersionWithDirectDriveReplicas() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
additionalReplicaSets: [{ regionalReplicaCount: 1, storageAccountType: "PreviumV2_LRS" }],
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: { allowDeletionOfReplicatedLocations: false },
storageProfile: {
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithAdditionalReplicaSets.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
AdditionalReplicaSets = {new AdditionalReplicaSet
{
StorageAccountType = new ImageStorageAccountType("PreviumV2_LRS"),
RegionalReplicaCount = 1,
}},
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"additionalReplicaSets": [
{
"storageAccountType": "PreviumV2_LRS",
"regionalReplicaCount": 1
}
],
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup//providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"additionalReplicaSets": [
{
"storageAccountType": "PreviumV2_LRS",
"regionalReplicaCount": 1
}
],
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
]
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup//providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"additionalReplicaSets": [
{
"storageAccountType": "PreviumV2_LRS",
"regionalReplicaCount": 1
}
],
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple gallery image version with target extended locations specified.
Solicitação de exemplo
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2024-03-03
{
"location": "West US",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
]
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
}
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"blockDeletionBeforeEndOfLife": false
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;
/**
* Samples for GalleryImageVersions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* GalleryImageVersion_Create_WithTargetExtendedLocations.json
*/
/**
* Sample code: Create or update a simple gallery image version with target extended locations specified.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryImageVersionWithTargetExtendedLocationsSpecified(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getGalleryImageVersions().createOrUpdate("myResourceGroup",
"myGalleryName", "myGalleryImageName", "1.0.0",
new GalleryImageVersionInner().withLocation("West US").withPublishingProfile(
new GalleryImageVersionPublishingProfile().withTargetRegions(Arrays.asList(new TargetRegion()
.withName("West US").withRegionalReplicaCount(
1)
.withEncryption(new EncryptionImages().withOsDiskImage(
new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false),
new TargetRegion().withName("East US").withRegionalReplicaCount(2)
.withStorageAccountType(StorageAccountType.STANDARD_ZRS)
.withEncryption(new EncryptionImages()
.withOsDiskImage(new OSDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
.withDataDiskImages(Arrays.asList(new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
.withLun(0),
new DataDiskImageEncryption().withDiskEncryptionSetId(
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
.withLun(1))))
.withExcludeFromLatest(false))))
.withStorageProfile(
new GalleryImageVersionStorageProfile().withSource(new GalleryArtifactVersionFullSource().withId(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
.withSafetyProfile(new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)
.withBlockDeletionBeforeEndOfLife(false)),
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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithTargetExtendedLocations.json
func ExampleGalleryImageVersionsClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryImageVersionWithTargetExtendedLocationsSpecified() {
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.NewGalleryImageVersionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", "myGalleryImageName", "1.0.0", armcompute.GalleryImageVersion{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryImageVersionProperties{
PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
TargetRegions: []*armcompute.TargetRegion{
{
Name: to.Ptr("West US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](1),
},
{
Name: to.Ptr("East US"),
Encryption: &armcompute.EncryptionImages{
DataDiskImages: []*armcompute.DataDiskImageEncryption{
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](0),
},
{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
Lun: to.Ptr[int32](1),
}},
OSDiskImage: &armcompute.OSDiskImageEncryption{
DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
},
ExcludeFromLatest: to.Ptr(false),
RegionalReplicaCount: to.Ptr[int32](2),
StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
}},
},
SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
AllowDeletionOfReplicatedLocations: to.Ptr(false),
BlockDeletionBeforeEndOfLife: to.Ptr(false),
},
StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
Source: &armcompute.GalleryArtifactVersionFullSource{
ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GalleryImageVersion = armcompute.GalleryImageVersion{
// Name: to.Ptr("1.0.0"),
// ID: to.Ptr("/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0"),
// Location: to.Ptr("West US"),
// Properties: &armcompute.GalleryImageVersionProperties{
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// PublishingProfile: &armcompute.GalleryImageVersionPublishingProfile{
// PublishedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()),
// ReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// TargetExtendedLocations: []*armcompute.GalleryTargetExtendedLocation{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExtendedLocation: &armcompute.GalleryExtendedLocation{
// Name: to.Ptr("microsoftlosangeles1"),
// Type: to.Ptr(armcompute.GalleryExtendedLocationTypeEdgeZone),
// },
// ExtendedLocationReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.EdgeZoneStorageAccountType("StandardSSD_LRS(default)")),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExtendedLocation: &armcompute.GalleryExtendedLocation{
// Name: to.Ptr("microsoftnewyork1"),
// Type: to.Ptr(armcompute.GalleryExtendedLocationTypeEdgeZone),
// },
// ExtendedLocationReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.EdgeZoneStorageAccountType("StandardSSD_LRS(default)")),
// }},
// TargetRegions: []*armcompute.TargetRegion{
// {
// Name: to.Ptr("West US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardLRS),
// },
// {
// Name: to.Ptr("East US"),
// Encryption: &armcompute.EncryptionImages{
// DataDiskImages: []*armcompute.DataDiskImageEncryption{
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](0),
// },
// {
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.OSDiskImageEncryption{
// DiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
// },
// },
// ExcludeFromLatest: to.Ptr(false),
// RegionalReplicaCount: to.Ptr[int32](2),
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypeStandardZRS),
// }},
// },
// SafetyProfile: &armcompute.GalleryImageVersionSafetyProfile{
// AllowDeletionOfReplicatedLocations: to.Ptr(false),
// BlockDeletionBeforeEndOfLife: to.Ptr(false),
// PolicyViolations: []*armcompute.PolicyViolation{
// {
// Category: to.Ptr(armcompute.PolicyViolationCategoryImageFlaggedUnsafe),
// Details: to.Ptr("This is the policy violation details."),
// }},
// ReportedForPolicyViolation: to.Ptr(true),
// },
// StorageProfile: &armcompute.GalleryImageVersionStorageProfile{
// DataDiskImages: []*armcompute.GalleryDataDiskImage{
// {
// HostCaching: to.Ptr(armcompute.HostCachingNone),
// SizeInGB: to.Ptr[int32](10),
// Lun: to.Ptr[int32](1),
// }},
// OSDiskImage: &armcompute.GalleryOSDiskImage{
// HostCaching: to.Ptr(armcompute.HostCachingReadOnly),
// SizeInGB: to.Ptr[int32](10),
// },
// Source: &armcompute.GalleryArtifactVersionFullSource{
// ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
// },
// },
// },
// }
}
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 Create or update a gallery image version.
*
* @summary Create or update a gallery image version.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithTargetExtendedLocations.json
*/
async function createOrUpdateASimpleGalleryImageVersionWithTargetExtendedLocationsSpecified() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const galleryImageName = "myGalleryImageName";
const galleryImageVersionName = "1.0.0";
const galleryImageVersion = {
location: "West US",
publishingProfile: {
targetRegions: [
{
name: "West US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 1,
},
{
name: "East US",
encryption: {
dataDiskImages: [
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet",
lun: 0,
},
{
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
lun: 1,
},
],
osDiskImage: {
diskEncryptionSetId:
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet",
},
},
excludeFromLatest: false,
regionalReplicaCount: 2,
storageAccountType: "Standard_ZRS",
},
],
},
safetyProfile: {
allowDeletionOfReplicatedLocations: false,
blockDeletionBeforeEndOfLife: false,
},
storageProfile: {
source: {
id: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}",
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleryImageVersions.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
galleryImageName,
galleryImageVersionName,
galleryImageVersion,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithTargetExtendedLocations.json
// this example is just showing the usage of "GalleryImageVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GalleryImageResource created on azure
// for more information of creating GalleryImageResource, please refer to the document of GalleryImageResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string galleryName = "myGalleryName";
string galleryImageName = "myGalleryImageName";
ResourceIdentifier galleryImageResourceId = GalleryImageResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName, galleryImageName);
GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId);
// get the collection of this GalleryImageVersionResource
GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions();
// invoke the operation
string galleryImageVersionName = "1.0.0";
GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US"))
{
PublishingProfile = new GalleryImageVersionPublishingProfile
{
TargetRegions = {new TargetRegion("West US")
{
RegionalReplicaCount = 1,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}, new TargetRegion("East US")
{
RegionalReplicaCount = 2,
StorageAccountType = ImageStorageAccountType.StandardZrs,
Encryption = new EncryptionImages
{
OSDiskImage = new OSDiskImageEncryption
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
},
DataDiskImages = {new DataDiskImageEncryption(0)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"),
}, new DataDiskImageEncryption(1)
{
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"),
}},
},
IsExcludedFromLatest = false,
}},
},
StorageProfile = new GalleryImageVersionStorageProfile
{
GallerySource = new GalleryArtifactVersionFullSource
{
Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"),
},
},
SafetyProfile = new GalleryImageVersionSafetyProfile
{
IsBlockedDeletionBeforeEndOfLife = false,
AllowDeletionOfReplicatedLocations = false,
},
};
ArmOperation<GalleryImageVersionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryImageVersionName, data);
GalleryImageVersionResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GalleryImageVersionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta de exemplo
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"targetExtendedLocations": [
{
"name": "West US",
"extendedLocation": {
"name": "microsoftlosangeles1",
"type": "EdgeZone"
},
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"storageAccountType": "StandardSSD_LRS(default)",
"extendedLocationReplicaCount": 1
},
{
"name": "East US",
"extendedLocation": {
"name": "microsoftnewyork1",
"type": "EdgeZone"
},
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"storageAccountType": "StandardSSD_LRS(default)",
"extendedLocationReplicaCount": 1
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "1.0.0"
}
{
"id": "/providers/Microsoft.Compute/locations/westus/Galleries/myGalleryName/Images/myGalleryImageName/Versions/1.0.0",
"properties": {
"publishingProfile": {
"targetRegions": [
{
"name": "West US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
},
{
"name": "East US",
"regionalReplicaCount": 2,
"storageAccountType": "Standard_ZRS",
"encryption": {
"osDiskImage": {
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
},
"dataDiskImages": [
{
"lun": 0,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"
},
{
"lun": 1,
"diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"
}
]
},
"excludeFromLatest": false
}
],
"replicaCount": 1,
"publishedDate": "2018-01-01T00:00:00Z",
"storageAccountType": "Standard_LRS"
},
"storageProfile": {
"source": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"
},
"osDiskImage": {
"sizeInGB": 10,
"hostCaching": "ReadOnly"
},
"dataDiskImages": [
{
"lun": 1,
"sizeInGB": 10,
"hostCaching": "None"
}
]
},
"safetyProfile": {
"allowDeletionOfReplicatedLocations": false,
"reportedForPolicyViolation": true,
"policyViolations": [
{
"category": "ImageFlaggedUnsafe",
"details": "This is the policy violation details."
}
],
"blockDeletionBeforeEndOfLife": false
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Definições
AdditionalReplicaSet
Descreve as informações adicionais do conjunto de réplicas.
Nome |
Tipo |
Description |
regionalReplicaCount
|
integer
|
O número de réplicas de unidade direta da Versão da Imagem a ser criada. Esta propriedade é atualizável
|
storageAccountType
|
StorageAccountType
|
Especifica o tipo de conta de armazenamento a ser usado para criar as réplicas de unidade direta
|
AggregatedReplicationState
Esse é o status de replicação agregado com base em todos os sinalizadores de status de replicação regionais.
Nome |
Tipo |
Description |
Completed
|
string
|
|
Failed
|
string
|
|
InProgress
|
string
|
|
Unknown
|
string
|
|
ApiError
Erro de API.
Nome |
Tipo |
Description |
code
|
string
|
O código de erro.
|
details
|
ApiErrorBase[]
|
Os detalhes do erro da API
|
innererror
|
InnerError
|
O erro interno da API
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro específico.
|
ApiErrorBase
Base de erros de API.
Nome |
Tipo |
Description |
code
|
string
|
O código de erro.
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro específico.
|
CloudError
Uma resposta de erro do serviço de computação.
Nome |
Tipo |
Description |
error
|
ApiError
|
Erro de API.
|
ConfidentialVMEncryptionType
tipos de criptografia de VM confidenciais
Nome |
Tipo |
Description |
EncryptedVMGuestStateOnlyWithPmk
|
string
|
|
EncryptedWithCmk
|
string
|
|
EncryptedWithPmk
|
string
|
|
NonPersistedTPM
|
string
|
|
DataDiskImageEncryption
Contém configurações de criptografia para uma imagem de disco de dados.
Nome |
Tipo |
Description |
diskEncryptionSetId
|
string
|
Um URI relativo que contém a ID do recurso do conjunto de criptografia de disco.
|
lun
|
integer
|
Essa propriedade especifica o número de unidade lógica do disco de dados. Esse valor é usado para identificar discos de dados dentro da Máquina Virtual e, portanto, deve ser exclusivo para cada disco de dados anexado à Máquina Virtual.
|
EdgeZoneStorageAccountType
Especifica o tipo de conta de armazenamento a ser usado para armazenar a imagem. Essa propriedade não é atualizável.
Nome |
Tipo |
Description |
Premium_LRS
|
string
|
|
StandardSSD_LRS
|
string
|
|
Standard_LRS
|
string
|
|
Standard_ZRS
|
string
|
|
EncryptionImages
Opcional. Permite que os usuários forneçam chaves gerenciadas pelo cliente para criptografar o sistema operacional e os discos de dados no artefato da galeria.
Nome |
Tipo |
Description |
dataDiskImages
|
DataDiskImageEncryption[]
|
Uma lista de especificações de criptografia para imagens de disco de dados.
|
osDiskImage
|
OSDiskImageEncryption
|
Contém configurações de criptografia para uma imagem de disco do sistema operacional.
|
ExecutedValidation
Essa é a validação executada.
Nome |
Tipo |
Description |
executionTime
|
string
|
Essa propriedade especifica o carimbo de data/hora inicial.
|
status
|
ValidationStatus
|
Essa propriedade especifica o status do validationProfile da versão da imagem.
|
type
|
string
|
Essa propriedade especifica o tipo de validação de versão da imagem.
|
version
|
string
|
Essa propriedade especifica a versão válida da validação.
|
GalleryArtifactVersionFullSource
A origem da versão do artefato da galeria.
Nome |
Tipo |
Description |
communityGalleryImageId
|
string
|
A ID do recurso da imagem da Galeria da Comunidade de origem. Necessário somente ao usar a Imagem da Galeria da Comunidade como fonte.
|
id
|
string
|
A ID da origem da versão do artefato da galeria.
|
virtualMachineId
|
string
|
A ID do recurso da máquina virtual de origem. Necessário somente ao capturar uma máquina virtual para a origem desta Versão de Imagem da Galeria.
|
GalleryDataDiskImage
Essa é a imagem do disco de dados.
Nome |
Tipo |
Description |
hostCaching
|
HostCaching
|
O cache do host do disco. Os valores válidos são 'None', 'ReadOnly' e 'ReadWrite'
|
lun
|
integer
|
Essa propriedade especifica o número de unidade lógica do disco de dados. Esse valor é usado para identificar discos de dados dentro da Máquina Virtual e, portanto, deve ser exclusivo para cada disco de dados anexado à Máquina Virtual.
|
sizeInGB
|
integer
|
Essa propriedade indica o tamanho do VHD a ser criado.
|
source
|
GalleryDiskImageSource
|
A origem da imagem de disco.
|
GalleryDiskImageSource
A origem da imagem de disco.
Nome |
Tipo |
Description |
id
|
string
|
A ID da origem da versão do artefato da galeria.
|
storageAccountId
|
string
|
A ID da Conta de Armazenamento que contém o blob de vhd que está sendo usado como fonte para esta versão do artefato.
|
uri
|
string
|
O uri da origem da versão do artefato da galeria. Atualmente usado para especificar a origem do vhd/blob.
|
GalleryExtendedLocation
O nome do local estendido.
GalleryExtendedLocationType
É o tipo do local estendido.
Nome |
Tipo |
Description |
EdgeZone
|
string
|
|
Unknown
|
string
|
|
GalleryImageVersion
Especifica informações sobre a versão da imagem da galeria que você deseja criar ou atualizar.
Nome |
Tipo |
Description |
id
|
string
|
ID do recurso
|
location
|
string
|
Local do recurso
|
name
|
string
|
Nome do recurso
|
properties.provisioningState
|
GalleryProvisioningState
|
O estado atual da galeria ou do artefato da galeria.
O estado de provisionamento, que aparece apenas na resposta.
|
properties.publishingProfile
|
GalleryImageVersionPublishingProfile
|
O perfil de publicação de uma versão de imagem da galeria.
|
properties.replicationStatus
|
ReplicationStatus
|
Esse é o status de replicação da versão da imagem da galeria.
|
properties.restore
|
boolean
|
Indica se essa é uma solicitação de restauração de recursos de exclusão reversível.
|
properties.safetyProfile
|
GalleryImageVersionSafetyProfile
|
Esse é o perfil de segurança da Versão da Imagem da Galeria.
|
properties.securityProfile
|
ImageVersionSecurityProfile
|
O perfil de segurança de uma versão de imagem da galeria
|
properties.storageProfile
|
GalleryImageVersionStorageProfile
|
Esse é o perfil de armazenamento de uma Versão de Imagem da Galeria.
|
properties.validationsProfile
|
ValidationsProfile
|
Esse é o perfil de validações de uma Versão de Imagem da Galeria.
|
tags
|
object
|
Marcas de recurso
|
type
|
string
|
Tipo de recurso
|
GalleryImageVersionPublishingProfile
O perfil de publicação de uma versão de imagem da galeria.
Nome |
Tipo |
Description |
endOfLifeDate
|
string
|
A data de término da vida útil da versão da imagem da galeria. Essa propriedade pode ser usada para fins de descomissionamento. Essa propriedade é atualizável.
|
excludeFromLatest
|
boolean
|
Se definido como true, as Máquinas Virtuais implantadas a partir da versão mais recente da Definição de Imagem não usarão essa Versão da Imagem.
|
publishedDate
|
string
|
O carimbo de data/hora para quando a versão da imagem da galeria é publicada.
|
replicaCount
|
integer
|
O número de réplicas da Versão da Imagem a serem criadas por região. Essa propriedade entraria em vigor para uma região quando regionalReplicaCount não for especificado. Essa propriedade é atualizável.
|
replicationMode
|
ReplicationMode
|
Parâmetro opcional que especifica o modo a ser usado para replicação. Essa propriedade não é atualizável.
|
storageAccountType
|
StorageAccountType
|
Especifica o tipo de conta de armazenamento a ser usado para armazenar a imagem. Essa propriedade não é atualizável.
|
targetExtendedLocations
|
GalleryTargetExtendedLocation[]
|
Os locais estendidos de destino para os quais a Versão da Imagem será replicada. Essa propriedade é atualizável.
|
targetRegions
|
TargetRegion[]
|
As regiões de destino para as quais a Versão da Imagem será replicada. Essa propriedade é atualizável.
|
GalleryImageVersionSafetyProfile
Esse é o perfil de segurança da Versão da Imagem da Galeria.
Nome |
Tipo |
Description |
allowDeletionOfReplicatedLocations
|
boolean
|
Indica se a remoção ou não dessa Versão da Imagem da Galeria de regiões replicadas é permitida.
|
blockDeletionBeforeEndOfLife
|
boolean
|
Indica se a exclusão está bloqueada ou não para esta Versão de Imagem da Galeria se o fim da vida útil não expirou.
|
policyViolations
|
PolicyViolation[]
|
Uma lista de Violações de Política que foram relatadas para esta Versão de Imagem da Galeria.
|
reportedForPolicyViolation
|
boolean
|
Indica se essa imagem foi relatada como violando as políticas da Microsoft.
|
GalleryImageVersionStorageProfile
Esse é o perfil de armazenamento de uma Versão de Imagem da Galeria.
GalleryImageVersionUefiSettings
Contém as configurações uefi para a versão da imagem.
Nome |
Tipo |
Description |
additionalSignatures
|
UefiKeySignatures
|
Assinaturas de chave UEFI adicionais que serão adicionadas à imagem, além dos modelos de assinatura
|
signatureTemplateNames
|
UefiSignatureTemplateName[]
|
O nome dos modelos que contém assinaturas de chave UEFI padrão que serão adicionadas à imagem.
|
GalleryOSDiskImage
Esta é a imagem de disco do sistema operacional.
Nome |
Tipo |
Description |
hostCaching
|
HostCaching
|
O cache do host do disco. Os valores válidos são 'None', 'ReadOnly' e 'ReadWrite'
|
sizeInGB
|
integer
|
Essa propriedade indica o tamanho do VHD a ser criado.
|
source
|
GalleryDiskImageSource
|
A origem da imagem de disco.
|
GalleryProvisioningState
O estado atual da galeria ou do artefato da galeria.
Nome |
Tipo |
Description |
Creating
|
string
|
|
Deleting
|
string
|
|
Failed
|
string
|
|
Migrating
|
string
|
|
Succeeded
|
string
|
|
Updating
|
string
|
|
GalleryTargetExtendedLocation
Nome |
Tipo |
Description |
encryption
|
EncryptionImages
|
Opcional. Permite que os usuários forneçam chaves gerenciadas pelo cliente para criptografar o sistema operacional e os discos de dados no artefato da galeria.
|
extendedLocation
|
GalleryExtendedLocation
|
O nome do local estendido.
|
extendedLocationReplicaCount
|
integer
|
O número de réplicas da Versão da Imagem a ser criada por local estendido. Essa propriedade é atualizável.
|
name
|
string
|
O nome da região.
|
storageAccountType
|
EdgeZoneStorageAccountType
|
Especifica o tipo de conta de armazenamento a ser usado para armazenar a imagem. Essa propriedade não é atualizável.
|
HostCaching
O cache do host do disco. Os valores válidos são 'None', 'ReadOnly' e 'ReadWrite'
Nome |
Tipo |
Description |
None
|
string
|
|
ReadOnly
|
string
|
|
ReadWrite
|
string
|
|
ImageVersionSecurityProfile
O perfil de segurança de uma versão de imagem da galeria
InnerError
Detalhes do erro interno.
Nome |
Tipo |
Description |
errordetail
|
string
|
A mensagem de erro interna ou o despejo de exceção.
|
exceptiontype
|
string
|
O tipo de exceção.
|
OSDiskImageEncryption
Contém configurações de criptografia para uma imagem de disco do sistema operacional.
Nome |
Tipo |
Description |
diskEncryptionSetId
|
string
|
Um URI relativo que contém a ID do recurso do conjunto de criptografia de disco.
|
securityProfile
|
OSDiskImageSecurityProfile
|
Essa propriedade especifica o perfil de segurança de uma imagem de disco do sistema operacional.
|
OSDiskImageSecurityProfile
Contém o perfil de segurança de uma imagem de disco do sistema operacional.
Nome |
Tipo |
Description |
confidentialVMEncryptionType
|
ConfidentialVMEncryptionType
|
tipos de criptografia de VM confidenciais
|
secureVMDiskEncryptionSetId
|
string
|
ID do conjunto de criptografia de disco de VM segura
|
Esse é o atributo de plataforma da versão da imagem.
Nome |
Tipo |
Description |
name
|
string
|
Essa propriedade especifica o nome da platformAttribute. É somente leitura.
|
value
|
string
|
Essa propriedade especifica o valor da propriedade de nome correspondente. É somente leitura.
|
PolicyViolation
Uma violação de política relatada contra um artefato da galeria.
Nome |
Tipo |
Description |
category
|
PolicyViolationCategory
|
Descreve a natureza da violação da política.
|
details
|
string
|
Descreve detalhes específicos sobre por que essa violação de política foi relatada.
|
PolicyViolationCategory
Descreve a natureza da violação da política.
Nome |
Tipo |
Description |
CopyrightValidation
|
string
|
|
ImageFlaggedUnsafe
|
string
|
|
IpTheft
|
string
|
|
Other
|
string
|
|
RegionalReplicationStatus
Esse é o status de replicação regional.
Nome |
Tipo |
Description |
details
|
string
|
Os detalhes do status de replicação.
|
progress
|
integer
|
Indica o progresso do trabalho de replicação.
|
region
|
string
|
A região para a qual a versão da imagem da galeria está sendo replicada.
|
state
|
ReplicationState
|
Esse é o estado de replicação regional.
|
ReplicationMode
Parâmetro opcional que especifica o modo a ser usado para replicação. Essa propriedade não é atualizável.
Nome |
Tipo |
Description |
Full
|
string
|
|
Shallow
|
string
|
|
ReplicationState
Esse é o estado de replicação regional.
Nome |
Tipo |
Description |
Completed
|
string
|
|
Failed
|
string
|
|
Replicating
|
string
|
|
Unknown
|
string
|
|
ReplicationStatus
Esse é o status de replicação da versão da imagem da galeria.
Nome |
Tipo |
Description |
aggregatedState
|
AggregatedReplicationState
|
Esse é o status de replicação agregado com base em todos os sinalizadores de status de replicação regionais.
|
summary
|
RegionalReplicationStatus[]
|
Este é um resumo do status de replicação para cada região.
|
StorageAccountType
Especifica o tipo de conta de armazenamento a ser usado para armazenar a imagem. Essa propriedade não é atualizável.
Nome |
Tipo |
Description |
PremiumV2_LRS
|
string
|
|
Premium_LRS
|
string
|
|
Standard_LRS
|
string
|
|
Standard_ZRS
|
string
|
|
TargetRegion
Descreve as informações da região de destino.
Nome |
Tipo |
Description |
additionalReplicaSets
|
AdditionalReplicaSet[]
|
Lista de sku de armazenamento com contagem de réplicas para criar réplicas de unidade direta.
|
encryption
|
EncryptionImages
|
Opcional. Permite que os usuários forneçam chaves gerenciadas pelo cliente para criptografar o sistema operacional e os discos de dados no artefato da galeria.
|
excludeFromLatest
|
boolean
|
Contém a configuração de sinalizador para ocultar uma imagem quando os usuários especificam version='latest'
|
name
|
string
|
O nome da região.
|
regionalReplicaCount
|
integer
|
O número de réplicas da Versão da Imagem a serem criadas por região. Essa propriedade é atualizável.
|
storageAccountType
|
StorageAccountType
|
Especifica o tipo de conta de armazenamento a ser usado para armazenar a imagem. Essa propriedade não é atualizável.
|
UefiKey
Uma assinatura de chave UEFI.
Nome |
Tipo |
Description |
type
|
UefiKeyType
|
O tipo de assinatura de chave.
|
value
|
string[]
|
O valor da assinatura de chave.
|
UefiKeySignatures
Assinaturas de chave UEFI adicionais que serão adicionadas à imagem, além dos modelos de assinatura
Nome |
Tipo |
Description |
db
|
UefiKey[]
|
O banco de dados de chaves UEFI para esta versão de imagem.
|
dbx
|
UefiKey[]
|
O banco de dados de chaves UEFI revogadas para esta versão de imagem.
|
kek
|
UefiKey[]
|
As Chaves de Criptografia de Chave desta versão da imagem.
|
pk
|
UefiKey
|
A Chave da Plataforma desta versão da imagem.
|
UefiKeyType
O tipo de assinatura de chave.
Nome |
Tipo |
Description |
sha256
|
string
|
|
x509
|
string
|
|
UefiSignatureTemplateName
O nome do modelo de assinatura que contém chaves UEFI padrão.
Nome |
Tipo |
Description |
MicrosoftUefiCertificateAuthorityTemplate
|
string
|
|
MicrosoftWindowsTemplate
|
string
|
|
NoSignatureTemplate
|
string
|
|
ValidationsProfile
Esse é o perfil de validações de uma Versão de Imagem da Galeria.
Nome |
Tipo |
Description |
executedValidations
|
ExecutedValidation[]
|
Essa é a validação executada.
|
platformAttributes
|
PlatformAttribute[]
|
Isso especifica o pub, a oferta, o sku e a versão dos metadados da versão da imagem
|
validationEtag
|
string
|
A hora publicada da versão da imagem
|
ValidationStatus
Essa propriedade especifica o status do validationProfile da versão da imagem.
Nome |
Tipo |
Description |
Failed
|
string
|
|
Succeeded
|
string
|
|
Unknown
|
string
|
|