Crie ou atualize uma Galeria de Imagens Partilhadas.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}?api-version=2025-03-03
Parâmetros do URI
| Name |
Em |
Necessário |
Tipo |
Description |
|
galleryName
|
path |
True
|
string
pattern: ^[^_\W][\w-._]{0,79}(?
|
O nome da Shared Image Gallery.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
O nome do grupo de recursos. O nome não diferencia maiúsculas de minúsculas.
|
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
O ID da assinatura de destino.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
A versão da API a utilizar para esta operação.
|
Corpo do Pedido
| Name |
Necessário |
Tipo |
Description |
|
location
|
True
|
string
|
A geolocalização onde o recurso vive
|
|
identity
|
|
GalleryIdentity
|
A identidade da galeria, se configurada.
|
|
properties.description
|
|
string
|
A descrição deste recurso da Galeria de Imagens Partilhadas. Esta propriedade é atualizável.
|
|
properties.identifier
|
|
GalleryIdentifier
|
Descreve o nome exclusivo da galeria.
|
|
properties.sharingProfile
|
|
SharingProfile
|
Perfil para compartilhamento de galeria para assinatura ou locatário
|
|
properties.softDeletePolicy
|
|
SoftDeletePolicy
|
Contém informações sobre a política de exclusão flexível da galeria.
|
|
tags
|
|
object
|
Tags de recursos.
|
Respostas
| Name |
Tipo |
Description |
|
200 OK
|
Gallery
|
Operação de atualização da 'Galeria' de recursos bem-sucedida
|
|
201 Created
|
Gallery
|
Operação de criação de 'Galeria' de recursos bem-sucedida
Cabeçalhos
- Location: string
- Retry-After: integer
|
|
202 Accepted
|
Gallery
|
O pedido foi aceite para processamento, mas o processamento ainda não foi concluído.
Cabeçalhos
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
CloudError
|
Uma resposta de erro inesperada.
|
Segurança
azure_auth
Azure Active Directory OAuth2 Flow.
Tipo:
oauth2
Fluxo:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Âmbitos
| Name |
Description |
|
user_impersonation
|
personificar a sua conta de utilizador
|
Exemplos
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03
{
"location": "West US",
"properties": {
"description": "This is the gallery description.",
"sharingProfile": {
"permissions": "Community",
"communityGalleryInfo": {
"publisherUri": "uri",
"publisherContact": "pir@microsoft.com",
"eula": "eula",
"publicNamePrefix": "PirPublic"
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryInner;
import com.azure.resourcemanager.compute.models.CommunityGalleryInfo;
import com.azure.resourcemanager.compute.models.GallerySharingPermissionTypes;
import com.azure.resourcemanager.compute.models.SharingProfile;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Galleries CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/CommunityGallery_Create.json
*/
/**
* Sample code: Create a community gallery.
*
* @param manager Entry point to ComputeManager.
*/
public static void createACommunityGallery(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().createOrUpdate("myResourceGroup", "myGalleryName",
new GalleryInner().withLocation("West US").withDescription("This is the gallery description.")
.withSharingProfile(new SharingProfile().withPermissions(GallerySharingPermissionTypes.COMMUNITY)
.withCommunityGalleryInfo(new CommunityGalleryInfo().withPublisherUri("uri")
.withPublisherContact("pir@microsoft.com").withEula("eula").withPublicNamePrefix("PirPublic"))),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python community_gallery_create.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.galleries.begin_create_or_update(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
gallery={
"location": "West US",
"properties": {
"description": "This is the gallery description.",
"sharingProfile": {
"communityGalleryInfo": {
"eula": "eula",
"publicNamePrefix": "PirPublic",
"publisherContact": "pir@microsoft.com",
"publisherUri": "uri",
},
"permissions": "Community",
},
},
},
).result()
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/CommunityGallery_Create.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/CommunityGallery_Create.json
func ExampleGalleriesClient_BeginCreateOrUpdate_createACommunityGallery() {
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.NewGalleriesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", armcompute.Gallery{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryProperties{
Description: to.Ptr("This is the gallery description."),
SharingProfile: &armcompute.SharingProfile{
Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesCommunity),
CommunityGalleryInfo: &armcompute.CommunityGalleryInfo{
PublisherURI: to.Ptr("uri"),
PublisherContact: to.Ptr("pir@microsoft.com"),
Eula: to.Ptr("eula"),
PublicNamePrefix: to.Ptr("PirPublic"),
},
},
},
}, 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 = armcompute.GalleriesClientCreateOrUpdateResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Properties: &armcompute.GalleryProperties{
// Description: to.Ptr("This is the gallery description."),
// Identifier: &armcompute.GalleryIdentifier{
// UniqueName: to.Ptr("{subscription-id}-MYGALLERYNAME"),
// },
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateUpdating),
// SharingProfile: &armcompute.SharingProfile{
// Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesCommunity),
// CommunityGalleryInfo: &armcompute.CommunityGalleryInfo{
// PublisherURI: to.Ptr("uri"),
// PublisherContact: to.Ptr("pir@microsoft.com"),
// Eula: to.Ptr("eula"),
// PublicNamePrefix: to.Ptr("PirPublic"),
// },
// },
// },
// Location: to.Ptr("West US"),
// Name: to.Ptr("myGalleryName"),
// },
// }
}
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 Shared Image Gallery.
*
* @summary create or update a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/CommunityGallery_Create.json
*/
async function createACommunityGallery() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.createOrUpdate("myResourceGroup", "myGalleryName", {
location: "West US",
description: "This is the gallery description.",
sharingProfile: {
permissions: "Community",
communityGalleryInfo: {
publisherUri: "uri",
publisherContact: "pir@microsoft.com",
eula: "eula",
publicNamePrefix: "PirPublic",
},
},
});
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-03-03/examples/galleryExamples/CommunityGallery_Create.json
// this example is just showing the usage of "Galleries_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://dotnet.territoriali.olinfo.it/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this GalleryResource
GalleryCollection collection = resourceGroupResource.GetGalleries();
// invoke the operation
string galleryName = "myGalleryName";
GalleryData data = new GalleryData(new AzureLocation("West US"))
{
Description = "This is the gallery description.",
SharingProfile = new SharingProfile
{
Permission = GallerySharingPermissionType.Community,
CommunityGalleryInfo = new CommunityGalleryInfo
{
PublisherUriString = "uri",
PublisherContact = "pir@microsoft.com",
Eula = "eula",
PublicNamePrefix = "PirPublic",
},
},
};
ArmOperation<GalleryResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data);
GalleryResource 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
GalleryData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"sharingProfile": {
"permissions": "Community",
"communityGalleryInfo": {
"publisherUri": "uri",
"publisherContact": "pir@microsoft.com",
"eula": "eula",
"publicNamePrefix": "PirPublic"
}
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Creating",
"sharingProfile": {
"permissions": "Community",
"communityGalleryInfo": {
"publisherUri": "uri",
"publisherContact": "pir@microsoft.com",
"eula": "eula",
"publicNamePrefix": "PirPublic"
}
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"sharingProfile": {
"permissions": "Community",
"communityGalleryInfo": {
"publisherUri": "uri",
"publisherContact": "pir@microsoft.com",
"eula": "eula",
"publicNamePrefix": "PirPublic"
}
}
},
"location": "West US",
"name": "myGalleryName"
}
Create or update a simple gallery with sharing profile.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03
{
"location": "West US",
"properties": {
"description": "This is the gallery description.",
"sharingProfile": {
"permissions": "Groups"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryInner;
import com.azure.resourcemanager.compute.models.GallerySharingPermissionTypes;
import com.azure.resourcemanager.compute.models.SharingProfile;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Galleries CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_WithSharingProfile.json
*/
/**
* Sample code: Create or update a simple gallery with sharing profile.
*
* @param manager Entry point to ComputeManager.
*/
public static void
createOrUpdateASimpleGalleryWithSharingProfile(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().createOrUpdate("myResourceGroup", "myGalleryName",
new GalleryInner().withLocation("West US").withDescription("This is the gallery description.")
.withSharingProfile(new SharingProfile().withPermissions(GallerySharingPermissionTypes.GROUPS)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_create_with_sharing_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.galleries.begin_create_or_update(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
gallery={
"location": "West US",
"properties": {
"description": "This is the gallery description.",
"sharingProfile": {"permissions": "Groups"},
},
},
).result()
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_WithSharingProfile.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Create_WithSharingProfile.json
func ExampleGalleriesClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryWithSharingProfile() {
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.NewGalleriesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", armcompute.Gallery{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryProperties{
Description: to.Ptr("This is the gallery description."),
SharingProfile: &armcompute.SharingProfile{
Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesGroups),
},
},
}, 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 = armcompute.GalleriesClientCreateOrUpdateResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Properties: &armcompute.GalleryProperties{
// Description: to.Ptr("This is the gallery description."),
// Identifier: &armcompute.GalleryIdentifier{
// UniqueName: to.Ptr("{subscription-id}-MYGALLERYNAME"),
// },
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateUpdating),
// SharingProfile: &armcompute.SharingProfile{
// Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesGroups),
// },
// },
// Location: to.Ptr("West US"),
// Name: to.Ptr("myGalleryName"),
// },
// }
}
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 Shared Image Gallery.
*
* @summary create or update a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_WithSharingProfile.json
*/
async function createOrUpdateASimpleGalleryWithSharingProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.createOrUpdate("myResourceGroup", "myGalleryName", {
location: "West US",
description: "This is the gallery description.",
sharingProfile: { permissions: "Groups" },
});
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-03-03/examples/galleryExamples/Gallery_Create_WithSharingProfile.json
// this example is just showing the usage of "Galleries_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://dotnet.territoriali.olinfo.it/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this GalleryResource
GalleryCollection collection = resourceGroupResource.GetGalleries();
// invoke the operation
string galleryName = "myGalleryName";
GalleryData data = new GalleryData(new AzureLocation("West US"))
{
Description = "This is the gallery description.",
SharingProfile = new SharingProfile
{
Permission = GallerySharingPermissionType.Groups,
},
};
ArmOperation<GalleryResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data);
GalleryResource 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
GalleryData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"sharingProfile": {
"permissions": "Groups"
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Creating",
"sharingProfile": {
"permissions": "Groups"
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"sharingProfile": {
"permissions": "Groups"
}
},
"location": "West US",
"name": "myGalleryName"
}
Create or update a simple gallery with soft deletion enabled.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03
{
"location": "West US",
"properties": {
"description": "This is the gallery description.",
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryInner;
import com.azure.resourcemanager.compute.models.SoftDeletePolicy;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Galleries CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_SoftDeletionEnabled.json
*/
/**
* Sample code: Create or update a simple gallery with soft deletion enabled.
*
* @param manager Entry point to ComputeManager.
*/
public static void
createOrUpdateASimpleGalleryWithSoftDeletionEnabled(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().createOrUpdate("myResourceGroup", "myGalleryName",
new GalleryInner().withLocation("West US").withDescription("This is the gallery description.")
.withSoftDeletePolicy(new SoftDeletePolicy().withIsSoftDeleteEnabled(true)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_create_soft_deletion_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.galleries.begin_create_or_update(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
gallery={
"location": "West US",
"properties": {
"description": "This is the gallery description.",
"softDeletePolicy": {"isSoftDeleteEnabled": True},
},
},
).result()
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_SoftDeletionEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Create_SoftDeletionEnabled.json
func ExampleGalleriesClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryWithSoftDeletionEnabled() {
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.NewGalleriesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", armcompute.Gallery{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryProperties{
Description: to.Ptr("This is the gallery description."),
SoftDeletePolicy: &armcompute.SoftDeletePolicy{
IsSoftDeleteEnabled: to.Ptr(true),
},
},
}, 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 = armcompute.GalleriesClientCreateOrUpdateResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Properties: &armcompute.GalleryProperties{
// Description: to.Ptr("This is the gallery description."),
// Identifier: &armcompute.GalleryIdentifier{
// UniqueName: to.Ptr("{subscription-id}-MYGALLERYNAME"),
// },
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateUpdating),
// SoftDeletePolicy: &armcompute.SoftDeletePolicy{
// IsSoftDeleteEnabled: to.Ptr(true),
// },
// },
// Location: to.Ptr("West US"),
// Name: to.Ptr("myGalleryName"),
// },
// }
}
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 Shared Image Gallery.
*
* @summary create or update a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_SoftDeletionEnabled.json
*/
async function createOrUpdateASimpleGalleryWithSoftDeletionEnabled() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.createOrUpdate("myResourceGroup", "myGalleryName", {
location: "West US",
description: "This is the gallery description.",
softDeletePolicy: { isSoftDeleteEnabled: true },
});
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-03-03/examples/galleryExamples/Gallery_Create_SoftDeletionEnabled.json
// this example is just showing the usage of "Galleries_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://dotnet.territoriali.olinfo.it/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this GalleryResource
GalleryCollection collection = resourceGroupResource.GetGalleries();
// invoke the operation
string galleryName = "myGalleryName";
GalleryData data = new GalleryData(new AzureLocation("West US"))
{
Description = "This is the gallery description.",
IsSoftDeleteEnabled = true,
};
ArmOperation<GalleryResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data);
GalleryResource 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
GalleryData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Creating",
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
},
"location": "West US",
"name": "myGalleryName"
}
Create or update a simple gallery with system-assigned and user-assigned managed identities.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03
{
"location": "West US",
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": {}
}
},
"properties": {
"description": "This is the gallery description."
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryInner;
import com.azure.resourcemanager.compute.models.GalleryIdentity;
import com.azure.resourcemanager.compute.models.ResourceIdentityType;
import com.azure.resourcemanager.compute.models.VirtualMachineIdentityUserAssignedIdentities;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Galleries CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_WithManagedIdentity.json
*/
/**
* Sample code: Create or update a simple gallery with system-assigned and user-assigned managed identities.
*
* @param manager Entry point to ComputeManager.
*/
public static void createOrUpdateASimpleGalleryWithSystemAssignedAndUserAssignedManagedIdentities(
com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().createOrUpdate("myResourceGroup", "myGalleryName", new GalleryInner()
.withLocation("West US")
.withIdentity(new GalleryIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity",
new VirtualMachineIdentityUserAssignedIdentities())))
.withDescription("This is the gallery description."), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_create_with_managed_identity.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.galleries.begin_create_or_update(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
gallery={
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": {}
},
},
"location": "West US",
"properties": {"description": "This is the gallery description."},
},
).result()
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_WithManagedIdentity.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Create_WithManagedIdentity.json
func ExampleGalleriesClient_BeginCreateOrUpdate_createOrUpdateASimpleGalleryWithSystemAssignedAndUserAssignedManagedIdentities() {
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.NewGalleriesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", armcompute.Gallery{
Location: to.Ptr("West US"),
Identity: &armcompute.GalleryIdentity{
Type: to.Ptr(armcompute.ResourceIdentityTypeSystemAssignedUserAssigned),
UserAssignedIdentities: map[string]*armcompute.UserAssignedIdentitiesValue{
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": {},
},
},
Properties: &armcompute.GalleryProperties{
Description: to.Ptr("This is the gallery description."),
},
}, 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 = armcompute.GalleriesClientCreateOrUpdateResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Identity: &armcompute.GalleryIdentity{
// Type: to.Ptr(armcompute.ResourceIdentityTypeSystemAssignedUserAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// UserAssignedIdentities: map[string]*armcompute.UserAssignedIdentitiesValue{
// "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": &armcompute.UserAssignedIdentitiesValue{
// },
// },
// },
// Properties: &armcompute.GalleryProperties{
// Description: to.Ptr("This is the gallery description."),
// Identifier: &armcompute.GalleryIdentifier{
// UniqueName: to.Ptr("{subscription-id}-MYGALLERYNAME"),
// },
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateUpdating),
// },
// Location: to.Ptr("West US"),
// Name: to.Ptr("myGalleryName"),
// },
// }
}
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 Shared Image Gallery.
*
* @summary create or update a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create_WithManagedIdentity.json
*/
async function createOrUpdateASimpleGalleryWithSystemAssignedAndUserAssignedManagedIdentities() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.createOrUpdate("myResourceGroup", "myGalleryName", {
location: "West US",
identity: {
type: "SystemAssigned, UserAssigned",
userAssignedIdentities: {
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity":
{},
},
},
description: "This is the gallery description.",
});
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-03-03/examples/galleryExamples/Gallery_Create_WithManagedIdentity.json
// this example is just showing the usage of "Galleries_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://dotnet.territoriali.olinfo.it/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this GalleryResource
GalleryCollection collection = resourceGroupResource.GetGalleries();
// invoke the operation
string galleryName = "myGalleryName";
GalleryData data = new GalleryData(new AzureLocation("West US"))
{
Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned")
{
UserAssignedIdentities =
{
[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity")] = new UserAssignedIdentity()
},
},
Description = "This is the gallery description.",
};
ArmOperation<GalleryResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data);
GalleryResource 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
GalleryData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"identity": {
"type": "SystemAssigned, UserAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": {}
}
},
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"identity": {
"type": "SystemAssigned, UserAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": {}
}
},
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Creating",
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"identity": {
"type": "SystemAssigned, UserAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity": {}
}
},
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating",
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
},
"location": "West US",
"name": "myGalleryName"
}
Create or update a simple gallery.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03
{
"location": "West US",
"properties": {
"description": "This is the gallery description."
}
}
import com.azure.resourcemanager.compute.fluent.models.GalleryInner;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Galleries CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create.json
*/
/**
* Sample code: Create or update a simple gallery.
*
* @param manager Entry point to ComputeManager.
*/
public static void createOrUpdateASimpleGallery(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().createOrUpdate("myResourceGroup", "myGalleryName",
new GalleryInner().withLocation("West US").withDescription("This is the gallery description."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_create.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.galleries.begin_create_or_update(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
gallery={"location": "West US", "properties": {"description": "This is the gallery description."}},
).result()
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Create.json
func ExampleGalleriesClient_BeginCreateOrUpdate_createOrUpdateASimpleGallery() {
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.NewGalleriesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myGalleryName", armcompute.Gallery{
Location: to.Ptr("West US"),
Properties: &armcompute.GalleryProperties{
Description: to.Ptr("This is the gallery description."),
},
}, 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 = armcompute.GalleriesClientCreateOrUpdateResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGallery"),
// Properties: &armcompute.GalleryProperties{
// Description: to.Ptr("This is the gallery description."),
// Identifier: &armcompute.GalleryIdentifier{
// UniqueName: to.Ptr("{subscription-id}-MYGALLERYNAME"),
// },
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateUpdating),
// },
// Location: to.Ptr("West US"),
// Name: to.Ptr("myGalleryName"),
// },
// }
}
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 Shared Image Gallery.
*
* @summary create or update a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Create.json
*/
async function createOrUpdateASimpleGallery() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.createOrUpdate("myResourceGroup", "myGalleryName", {
location: "West US",
description: "This is the gallery description.",
});
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-03-03/examples/galleryExamples/Gallery_Create.json
// this example is just showing the usage of "Galleries_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://dotnet.territoriali.olinfo.it/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this GalleryResource
GalleryCollection collection = resourceGroupResource.GetGalleries();
// invoke the operation
string galleryName = "myGalleryName";
GalleryData data = new GalleryData(new AzureLocation("West US"))
{
Description = "This is the gallery description.",
};
ArmOperation<GalleryResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data);
GalleryResource 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
GalleryData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGallery",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGallery",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Creating"
},
"location": "West US",
"name": "myGalleryName"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGallery",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Updating"
},
"location": "West US",
"name": "myGalleryName"
}
Definições
| Name |
Description |
|
ApiError
|
Erro de api.
|
|
ApiErrorBase
|
Base de erro da api.
|
|
CloudError
|
Uma resposta de erro do serviço de computação.
|
|
Common.UserAssignedIdentitiesValue
|
|
|
CommunityGalleryInfo
|
Informações da galeria da comunidade se a galeria atual for compartilhada com a comunidade
|
|
createdByType
|
O tipo de identidade que criou o recurso.
|
|
Gallery
|
Especifica informações sobre a Galeria de Imagens Compartilhadas que você deseja criar ou atualizar.
|
|
GalleryIdentifier
|
Descreve o nome exclusivo da galeria.
|
|
GalleryIdentity
|
Identidade para a máquina virtual.
|
|
GalleryProvisioningState
|
O estado de provisionamento, que só aparece na resposta.
|
|
GallerySharingPermissionTypes
|
Esta propriedade permite que você especifique a permissão de compartilhamento da galeria. Os valores possíveis são: Privado,GruposComunidade.
|
|
InnerError
|
Detalhes do erro interno.
|
|
RegionalSharingStatus
|
Estado de partilha regional da galeria
|
|
ResourceIdentityType
|
O tipo de identidade usado para a galeria. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'Nenhum' removerá todas as identidades da galeria.
|
|
SharingProfile
|
Perfil para compartilhamento de galeria para assinatura ou locatário
|
|
SharingProfileGroup
|
Grupo do perfil de partilha da galeria
|
|
SharingProfileGroupTypes
|
Esta propriedade permite especificar o tipo de grupo de compartilhamento. Os valores possíveis são: Assinaturas,AADTenants.
|
|
SharingState
|
O estado de compartilhamento da galeria, que só aparece na resposta.
|
|
SharingStatus
|
Status de compartilhamento da galeria atual.
|
|
SoftDeletePolicy
|
Contém informações sobre a política de exclusão flexível da galeria.
|
|
systemData
|
Metadados referentes à criação e última modificação do recurso.
|
ApiError
Object
Erro de api.
| Name |
Tipo |
Description |
|
code
|
string
|
O código de erro.
|
|
details
|
ApiErrorBase[]
|
Os detalhes do erro Api
|
|
innererror
|
InnerError
|
O erro interno da Api
|
|
message
|
string
|
A mensagem de erro.
|
|
target
|
string
|
O alvo do erro específico.
|
ApiErrorBase
Object
Base de erro da api.
| Name |
Tipo |
Description |
|
code
|
string
|
O código de erro.
|
|
message
|
string
|
A mensagem de erro.
|
|
target
|
string
|
O alvo do erro específico.
|
CloudError
Object
Uma resposta de erro do serviço de computação.
| Name |
Tipo |
Description |
|
error
|
ApiError
|
Erro de api.
|
Common.UserAssignedIdentitiesValue
Object
| Name |
Tipo |
Description |
|
clientId
|
string
|
O ID do cliente da identidade atribuída ao usuário.
|
|
principalId
|
string
|
O id principal da identidade atribuída ao usuário.
|
Object
Informações da galeria da comunidade se a galeria atual for compartilhada com a comunidade
| Name |
Tipo |
Description |
|
communityGalleryEnabled
|
boolean
|
Contém informações sobre se o compartilhamento da galeria da comunidade está habilitado.
|
|
eula
|
string
|
Contrato de licença de utilizador final para a imagem da galeria da comunidade.
|
|
publicNamePrefix
|
string
|
O prefixo do nome da galeria que será exibido publicamente. Visível para todos os usuários.
|
|
publicNames
|
string[]
|
Lista de nomes públicos da galeria da comunidade.
|
|
publisherContact
|
string
|
E-mail de suporte do editor da galeria da comunidade. O endereço de e-mail do editor. Visível para todos os usuários.
|
|
publisherUri
|
string
|
O link para o site da editora. Visível para todos os usuários.
|
createdByType
Enumeração
O tipo de identidade que criou o recurso.
| Valor |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
Gallery
Object
Especifica informações sobre a Galeria de Imagens Compartilhadas que você deseja criar ou atualizar.
| Name |
Tipo |
Description |
|
id
|
string
|
ID de recurso totalmente qualificado para o recurso. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
identity
|
GalleryIdentity
|
A identidade da galeria, se configurada.
|
|
location
|
string
|
A geolocalização onde o recurso vive
|
|
name
|
string
|
O nome do recurso
|
|
properties.description
|
string
|
A descrição deste recurso da Galeria de Imagens Partilhadas. Esta propriedade é atualizável.
|
|
properties.identifier
|
GalleryIdentifier
|
Descreve o nome exclusivo da galeria.
|
|
properties.provisioningState
|
GalleryProvisioningState
|
O estado de provisionamento, que só aparece na resposta.
|
|
properties.sharingProfile
|
SharingProfile
|
Perfil para compartilhamento de galeria para assinatura ou locatário
|
|
properties.sharingStatus
|
SharingStatus
|
Status de compartilhamento da galeria atual.
|
|
properties.softDeletePolicy
|
SoftDeletePolicy
|
Contém informações sobre a política de exclusão flexível da galeria.
|
|
systemData
|
systemData
|
Metadados do Azure Resource Manager contendo informações createdBy e modifiedBy.
|
|
tags
|
object
|
Tags de recursos.
|
|
type
|
string
|
O tipo do recurso. Por exemplo, "Microsoft. Computação/Máquinas Virtuais" ou "Microsoft. ContasArmazenamento/Armazenamento"
|
GalleryIdentifier
Object
Descreve o nome exclusivo da galeria.
| Name |
Tipo |
Description |
|
uniqueName
|
string
|
O nome único da Shared Image Gallery. Esse nome é gerado automaticamente pelo Azure.
|
GalleryIdentity
Object
Identidade para a máquina virtual.
| Name |
Tipo |
Description |
|
principalId
|
string
|
O id principal da identidade da galeria. Esta propriedade só será fornecida para uma identidade atribuída ao sistema.
|
|
tenantId
|
string
|
O ID de locatário do AAD da identidade da galeria. Esta propriedade só será fornecida para uma identidade atribuída ao sistema.
|
|
type
|
ResourceIdentityType
|
O tipo de identidade usado para a galeria. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'Nenhum' removerá todas as identidades da galeria.
|
|
userAssignedIdentities
|
<string,
Common.UserAssignedIdentitiesValue>
|
A lista de identidades de usuário associadas à galeria. As referências-chave do dicionário de identidade do utilizador serão IDs de recursos ARM na forma: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft. ManagedIdentity/userAssignedIdentities/{identityName}'.
|
GalleryProvisioningState
Enumeração
O estado de provisionamento, que só aparece na resposta.
| Valor |
Description |
|
Creating
|
|
|
Updating
|
|
|
Failed
|
|
|
Succeeded
|
|
|
Deleting
|
|
|
Migrating
|
|
GallerySharingPermissionTypes
Enumeração
Esta propriedade permite que você especifique a permissão de compartilhamento da galeria. Os valores possíveis são: Privado,GruposComunidade.
| Valor |
Description |
|
Private
|
|
|
Groups
|
|
|
Community
|
|
InnerError
Object
Detalhes do erro interno.
| Name |
Tipo |
Description |
|
errordetail
|
string
|
A mensagem de erro interna ou despejo de exceção.
|
|
exceptiontype
|
string
|
O tipo de exceção.
|
RegionalSharingStatus
Object
Estado de partilha regional da galeria
| Name |
Tipo |
Description |
|
details
|
string
|
Detalhes da falha de compartilhamento regional da galeria.
|
|
region
|
string
|
Nome da região
|
|
state
|
SharingState
|
Estado de compartilhamento da galeria na região atual
|
ResourceIdentityType
Enumeração
O tipo de identidade usado para a galeria. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'Nenhum' removerá todas as identidades da galeria.
| Valor |
Description |
|
SystemAssigned
|
|
|
UserAssigned
|
|
|
SystemAssigned, UserAssigned
|
|
|
None
|
|
SharingProfile
Object
Perfil para compartilhamento de galeria para assinatura ou locatário
| Name |
Tipo |
Description |
|
communityGalleryInfo
|
CommunityGalleryInfo
|
Informações da galeria da comunidade se a galeria atual for compartilhada com a comunidade.
|
|
groups
|
SharingProfileGroup[]
|
Uma lista de grupos de perfis de compartilhamento.
|
|
permissions
|
GallerySharingPermissionTypes
|
Esta propriedade permite que você especifique a permissão de compartilhamento da galeria. Os valores possíveis são: Privado,GruposComunidade.
|
SharingProfileGroup
Object
Grupo do perfil de partilha da galeria
| Name |
Tipo |
Description |
|
ids
|
string[]
|
Uma lista de IDs de assinatura/locatário com os quais a galeria deve ser compartilhada.
|
|
type
|
SharingProfileGroupTypes
|
Esta propriedade permite especificar o tipo de grupo de compartilhamento. Os valores possíveis são: Assinaturas,AADTenants.
|
SharingProfileGroupTypes
Enumeração
Esta propriedade permite especificar o tipo de grupo de compartilhamento. Os valores possíveis são: Assinaturas,AADTenants.
| Valor |
Description |
|
Subscriptions
|
|
|
AADTenants
|
|
SharingState
Enumeração
O estado de compartilhamento da galeria, que só aparece na resposta.
| Valor |
Description |
|
Succeeded
|
|
|
InProgress
|
|
|
Failed
|
|
|
Unknown
|
|
SharingStatus
Object
Status de compartilhamento da galeria atual.
| Name |
Tipo |
Description |
|
aggregatedState
|
SharingState
|
Estado de compartilhamento agregado da galeria atual.
|
|
summary
|
RegionalSharingStatus[]
|
Resumo de todo o status de compartilhamento regional.
|
SoftDeletePolicy
Object
Contém informações sobre a política de exclusão flexível da galeria.
| Name |
Tipo |
Description |
|
isSoftDeleteEnabled
|
boolean
|
Permite a exclusão suave de recursos nesta galeria, permitindo que eles sejam recuperados dentro do tempo de retenção.
|
systemData
Object
Metadados referentes à criação e última modificação do recurso.
| Name |
Tipo |
Description |
|
createdAt
|
string
(date-time)
|
O carimbo de data/hora da criação de recursos (UTC).
|
|
createdBy
|
string
|
A identidade que criou o recurso.
|
|
createdByType
|
createdByType
|
O tipo de identidade que criou o recurso.
|
|
lastModifiedAt
|
string
(date-time)
|
O carimbo de data/hora da última modificação do recurso (UTC)
|
|
lastModifiedBy
|
string
|
A identidade que modificou o recurso pela última vez.
|
|
lastModifiedByType
|
createdByType
|
O tipo de identidade que modificou o recurso pela última vez.
|