Create or update a gallery image version.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}?api-version=2023-07-03
URI Parameters
Name |
In |
Required |
Type |
Description |
galleryImageName
|
path |
True
|
string
|
The name of the gallery image definition in which the Image Version is to be created.
|
galleryImageVersionName
|
path |
True
|
string
|
The name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: ..
|
galleryName
|
path |
True
|
string
|
The name of the Shared Image Gallery in which the Image Definition resides.
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group.
|
subscriptionId
|
path |
True
|
string
|
Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
|
api-version
|
query |
True
|
string
|
Client Api Version.
|
Request Body
Responses
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using managed image as source.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"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.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using shallow replication mode.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using shared image as source.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using snapshots as a source.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"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.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
},
"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/2023-07-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))
.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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"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.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple Gallery Image Version using VM as source.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Create or update a simple gallery image version with target extended locations specified.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/images/myGalleryImageName/versions/1.0.0?api-version=2023-07-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
}
}
}
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/2023-07-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)),
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/c7b98b36e4023331545051284d8500adf98f02fe/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-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),
},
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),
// 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/2023-07-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 },
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/2023-07-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()
{
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
Sample response
{
"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."
}
]
},
"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."
}
]
},
"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."
}
]
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "1.0.0"
}
Definitions
AggregatedReplicationState
This is the aggregated replication status based on all the regional replication status flags.
Name |
Type |
Description |
Completed
|
string
|
|
Failed
|
string
|
|
InProgress
|
string
|
|
Unknown
|
string
|
|
ApiError
Api error.
Name |
Type |
Description |
code
|
string
|
The error code.
|
details
|
ApiErrorBase[]
|
The Api error details
|
innererror
|
InnerError
|
The Api inner error
|
message
|
string
|
The error message.
|
target
|
string
|
The target of the particular error.
|
ApiErrorBase
Api error base.
Name |
Type |
Description |
code
|
string
|
The error code.
|
message
|
string
|
The error message.
|
target
|
string
|
The target of the particular error.
|
CloudError
An error response from the Compute service.
Name |
Type |
Description |
error
|
ApiError
|
Api error.
|
ConfidentialVMEncryptionType
confidential VM encryption types
Name |
Type |
Description |
EncryptedVMGuestStateOnlyWithPmk
|
string
|
|
EncryptedWithCmk
|
string
|
|
EncryptedWithPmk
|
string
|
|
NonPersistedTPM
|
string
|
|
DataDiskImageEncryption
Contains encryption settings for a data disk image.
Name |
Type |
Description |
diskEncryptionSetId
|
string
|
A relative URI containing the resource ID of the disk encryption set.
|
lun
|
integer
|
This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.
|
EdgeZoneStorageAccountType
Specifies the storage account type to be used to store the image. This property is not updatable.
Name |
Type |
Description |
Premium_LRS
|
string
|
|
StandardSSD_LRS
|
string
|
|
Standard_LRS
|
string
|
|
Standard_ZRS
|
string
|
|
EncryptionImages
Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in the gallery artifact.
GalleryArtifactVersionFullSource
The source of the gallery artifact version.
Name |
Type |
Description |
communityGalleryImageId
|
string
|
The resource Id of the source Community Gallery Image. Only required when using Community Gallery Image as a source.
|
id
|
string
|
The id of the gallery artifact version source.
|
virtualMachineId
|
string
|
The resource Id of the source virtual machine. Only required when capturing a virtual machine to source this Gallery Image Version.
|
GalleryDataDiskImage
This is the data disk image.
Name |
Type |
Description |
hostCaching
|
HostCaching
|
The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'
|
lun
|
integer
|
This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.
|
sizeInGB
|
integer
|
This property indicates the size of the VHD to be created.
|
source
|
GalleryDiskImageSource
|
The source for the disk image.
|
GalleryDiskImageSource
The source for the disk image.
Name |
Type |
Description |
id
|
string
|
The id of the gallery artifact version source.
|
storageAccountId
|
string
|
The Storage Account Id that contains the vhd blob being used as a source for this artifact version.
|
uri
|
string
|
The uri of the gallery artifact version source. Currently used to specify vhd/blob source.
|
GalleryExtendedLocation
The name of the extended location.
GalleryExtendedLocationType
It is type of the extended location.
Name |
Type |
Description |
EdgeZone
|
string
|
|
Unknown
|
string
|
|
GalleryImageVersion
Specifies information about the gallery image version that you want to create or update.
Name |
Type |
Description |
id
|
string
|
Resource Id
|
location
|
string
|
Resource location
|
name
|
string
|
Resource name
|
properties.provisioningState
|
GalleryProvisioningState
|
The current state of the gallery or gallery artifact.
The provisioning state, which only appears in the response.
|
properties.publishingProfile
|
GalleryImageVersionPublishingProfile
|
The publishing profile of a gallery image Version.
|
properties.replicationStatus
|
ReplicationStatus
|
This is the replication status of the gallery image version.
|
properties.safetyProfile
|
GalleryImageVersionSafetyProfile
|
This is the safety profile of the Gallery Image Version.
|
properties.securityProfile
|
ImageVersionSecurityProfile
|
The security profile of a gallery image version
|
properties.storageProfile
|
GalleryImageVersionStorageProfile
|
This is the storage profile of a Gallery Image Version.
|
tags
|
object
|
Resource tags
|
type
|
string
|
Resource type
|
GalleryImageVersionPublishingProfile
The publishing profile of a gallery image Version.
Name |
Type |
Description |
endOfLifeDate
|
string
|
The end of life date of the gallery image version. This property can be used for decommissioning purposes. This property is updatable.
|
excludeFromLatest
|
boolean
|
If set to true, Virtual Machines deployed from the latest version of the Image Definition won't use this Image Version.
|
publishedDate
|
string
|
The timestamp for when the gallery image version is published.
|
replicaCount
|
integer
|
The number of replicas of the Image Version to be created per region. This property would take effect for a region when regionalReplicaCount is not specified. This property is updatable.
|
replicationMode
|
ReplicationMode
|
Optional parameter which specifies the mode to be used for replication. This property is not updatable.
|
storageAccountType
|
StorageAccountType
|
Specifies the storage account type to be used to store the image. This property is not updatable.
|
targetExtendedLocations
|
GalleryTargetExtendedLocation[]
|
The target extended locations where the Image Version is going to be replicated to. This property is updatable.
|
targetRegions
|
TargetRegion[]
|
The target regions where the Image Version is going to be replicated to. This property is updatable.
|
GalleryImageVersionSafetyProfile
This is the safety profile of the Gallery Image Version.
Name |
Type |
Description |
allowDeletionOfReplicatedLocations
|
boolean
|
Indicates whether or not removing this Gallery Image Version from replicated regions is allowed.
|
policyViolations
|
PolicyViolation[]
|
A list of Policy Violations that have been reported for this Gallery Image Version.
|
reportedForPolicyViolation
|
boolean
|
Indicates whether this image has been reported as violating Microsoft's policies.
|
GalleryImageVersionStorageProfile
This is the storage profile of a Gallery Image Version.
GalleryImageVersionUefiSettings
Contains UEFI settings for the image version.
Name |
Type |
Description |
additionalSignatures
|
UefiKeySignatures
|
Additional UEFI key signatures that will be added to the image in addition to the signature templates
|
signatureTemplateNames
|
UefiSignatureTemplateName[]
|
The name of the template(s) that contains default UEFI key signatures that will be added to the image.
|
GalleryOSDiskImage
This is the OS disk image.
Name |
Type |
Description |
hostCaching
|
HostCaching
|
The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'
|
sizeInGB
|
integer
|
This property indicates the size of the VHD to be created.
|
source
|
GalleryDiskImageSource
|
The source for the disk image.
|
GalleryProvisioningState
The current state of the gallery or gallery artifact.
Name |
Type |
Description |
Creating
|
string
|
|
Deleting
|
string
|
|
Failed
|
string
|
|
Migrating
|
string
|
|
Succeeded
|
string
|
|
Updating
|
string
|
|
GalleryTargetExtendedLocation
Name |
Type |
Description |
encryption
|
EncryptionImages
|
Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in the gallery artifact.
|
extendedLocation
|
GalleryExtendedLocation
|
The name of the extended location.
|
extendedLocationReplicaCount
|
integer
|
The number of replicas of the Image Version to be created per extended location. This property is updatable.
|
name
|
string
|
The name of the region.
|
storageAccountType
|
EdgeZoneStorageAccountType
|
Specifies the storage account type to be used to store the image. This property is not updatable.
|
HostCaching
The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'
Name |
Type |
Description |
None
|
string
|
|
ReadOnly
|
string
|
|
ReadWrite
|
string
|
|
ImageVersionSecurityProfile
The security profile of a gallery image version
InnerError
Inner error details.
Name |
Type |
Description |
errordetail
|
string
|
The internal error message or exception dump.
|
exceptiontype
|
string
|
The exception type.
|
OSDiskImageEncryption
Contains encryption settings for an OS disk image.
Name |
Type |
Description |
diskEncryptionSetId
|
string
|
A relative URI containing the resource ID of the disk encryption set.
|
securityProfile
|
OSDiskImageSecurityProfile
|
This property specifies the security profile of an OS disk image.
|
OSDiskImageSecurityProfile
Contains security profile for an OS disk image.
Name |
Type |
Description |
confidentialVMEncryptionType
|
ConfidentialVMEncryptionType
|
confidential VM encryption types
|
secureVMDiskEncryptionSetId
|
string
|
secure VM disk encryption set id
|
PolicyViolation
A policy violation reported against a gallery artifact.
Name |
Type |
Description |
category
|
PolicyViolationCategory
|
Describes the nature of the policy violation.
|
details
|
string
|
Describes specific details about why this policy violation was reported.
|
PolicyViolationCategory
Describes the nature of the policy violation.
Name |
Type |
Description |
CopyrightValidation
|
string
|
|
ImageFlaggedUnsafe
|
string
|
|
IpTheft
|
string
|
|
Other
|
string
|
|
RegionalReplicationStatus
This is the regional replication status.
Name |
Type |
Description |
details
|
string
|
The details of the replication status.
|
progress
|
integer
|
It indicates progress of the replication job.
|
region
|
string
|
The region to which the gallery image version is being replicated to.
|
state
|
ReplicationState
|
This is the regional replication state.
|
ReplicationMode
Optional parameter which specifies the mode to be used for replication. This property is not updatable.
Name |
Type |
Description |
Full
|
string
|
|
Shallow
|
string
|
|
ReplicationState
This is the regional replication state.
Name |
Type |
Description |
Completed
|
string
|
|
Failed
|
string
|
|
Replicating
|
string
|
|
Unknown
|
string
|
|
ReplicationStatus
This is the replication status of the gallery image version.
StorageAccountType
Specifies the storage account type to be used to store the image. This property is not updatable.
Name |
Type |
Description |
Premium_LRS
|
string
|
|
Standard_LRS
|
string
|
|
Standard_ZRS
|
string
|
|
TargetRegion
Describes the target region information.
Name |
Type |
Description |
encryption
|
EncryptionImages
|
Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in the gallery artifact.
|
excludeFromLatest
|
boolean
|
Contains the flag setting to hide an image when users specify version='latest'
|
name
|
string
|
The name of the region.
|
regionalReplicaCount
|
integer
|
The number of replicas of the Image Version to be created per region. This property is updatable.
|
storageAccountType
|
StorageAccountType
|
Specifies the storage account type to be used to store the image. This property is not updatable.
|
UefiKey
A UEFI key signature.
Name |
Type |
Description |
type
|
UefiKeyType
|
The type of key signature.
|
value
|
string[]
|
The value of the key signature.
|
UefiKeySignatures
Additional UEFI key signatures that will be added to the image in addition to the signature templates
Name |
Type |
Description |
db
|
UefiKey[]
|
The database of UEFI keys for this image version.
|
dbx
|
UefiKey[]
|
The database of revoked UEFI keys for this image version.
|
kek
|
UefiKey[]
|
The Key Encryption Keys of this image version.
|
pk
|
UefiKey
|
The Platform Key of this image version.
|
UefiKeyType
The type of key signature.
Name |
Type |
Description |
sha256
|
string
|
|
x509
|
string
|
|
UefiSignatureTemplateName
The name of the signature template that contains default UEFI keys.
Name |
Type |
Description |
MicrosoftUefiCertificateAuthorityTemplate
|
string
|
|
MicrosoftWindowsTemplate
|
string
|
|
NoSignatureTemplate
|
string
|
|