Retrieves information about a Shared Image Gallery.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}?api-version=2025-03-03
With optional parameters:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}?api-version=2025-03-03&$select=Permissions&$expand=SharingProfile/Groups
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
galleryName
|
path |
True
|
string
pattern: ^[^_\W][\w-._]{0,79}(?
|
The name of the Shared Image Gallery.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
The ID of the target subscription.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
|
$expand
|
query |
|
GalleryExpandParams
|
The expand query option to apply on the operation.
|
|
$select
|
query |
|
SelectPermissions
|
The select expression to apply on the operation.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
Gallery
|
Azure operation completed successfully.
|
|
Other Status Codes
|
CloudError
|
An unexpected error response.
|
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
GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03&$select=Permissions&$expand=SharingProfile/Groups
/**
* Samples for Galleries GetByResourceGroup.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/CommunityGallery_Get.json
*/
/**
* Sample code: Get a community gallery.
*
* @param manager Entry point to ComputeManager.
*/
public static void getACommunityGallery(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().getByResourceGroupWithResponse("myResourceGroup", "myGalleryName", null,
null, 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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/CommunityGallery_Get.json
func ExampleGalleriesClient_Get_getACommunityGallery() {
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)
}
res, err := clientFactory.NewGalleriesClient().Get(ctx, "myResourceGroup", "myGalleryName", nil)
if err != nil {
log.Fatalf("failed to finish the request: %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.GalleriesClientGetResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/communityGalleries/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.GalleryProvisioningStateSucceeded),
// 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"),
// PublicNames: []*string{
// to.Ptr("GalleryPublicName"),
// },
// CommunityGalleryEnabled: to.Ptr(true),
// },
// },
// SharingStatus: &armcompute.SharingStatus{
// AggregatedState: to.Ptr(armcompute.SharingStateSucceeded),
// Summary: []*armcompute.RegionalSharingStatus{
// {
// Region: to.Ptr("westus"),
// State: to.Ptr(armcompute.SharingStateSucceeded),
// Details: to.Ptr(""),
// },
// },
// },
// },
// 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 retrieves information about a Shared Image Gallery.
*
* @summary retrieves information about a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/CommunityGallery_Get.json
*/
async function getACommunityGallery() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.get("myResourceGroup", "myGalleryName");
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_Get.json
// this example is just showing the usage of "Galleries_Get" 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 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";
NullableResponse<GalleryResource> response = await collection.GetIfExistsAsync(galleryName);
GalleryResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// 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
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/communityGalleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Succeeded",
"sharingProfile": {
"permissions": "Community",
"communityGalleryInfo": {
"publisherUri": "uri",
"publisherContact": "pir@microsoft.com",
"eula": "eula",
"publicNames": [
"GalleryPublicName"
],
"communityGalleryEnabled": true
}
},
"sharingStatus": {
"aggregatedState": "Succeeded",
"summary": [
{
"region": "westus",
"state": "Succeeded",
"details": ""
}
]
}
},
"location": "West US",
"name": "myGalleryName"
}
Get a gallery with expand sharingProfile groups.
Sample request
GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03&$select=Permissions&$expand=SharingProfile/Groups
import com.azure.resourcemanager.compute.models.GalleryExpandParams;
/**
* Samples for Galleries GetByResourceGroup.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json
*/
/**
* Sample code: Get a gallery with expand sharingProfile groups.
*
* @param manager Entry point to ComputeManager.
*/
public static void
getAGalleryWithExpandSharingProfileGroups(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().getByResourceGroupWithResponse("myResourceGroup", "myGalleryName", null,
GalleryExpandParams.SHARING_PROFILE_GROUPS, 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/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json
func ExampleGalleriesClient_Get_getAGalleryWithExpandSharingProfileGroups() {
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)
}
res, err := clientFactory.NewGalleriesClient().Get(ctx, "myResourceGroup", "myGalleryName", &armcompute.GalleriesClientGetOptions{
Expand: to.Ptr(armcompute.GalleryExpandParamsSharingProfileGroups)})
if err != nil {
log.Fatalf("failed to finish the request: %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.GalleriesClientGetResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Properties: &armcompute.GalleryProperties{
// SharingProfile: &armcompute.SharingProfile{
// Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesGroups),
// Groups: []*armcompute.SharingProfileGroup{
// {
// Type: to.Ptr(armcompute.SharingProfileGroupTypesSubscriptions),
// IDs: []*string{
// to.Ptr("34a4ab42-0d72-47d9-bd1a-aed207386dac"),
// to.Ptr("380fd389-260b-41aa-bad9-0a83108c370b"),
// },
// },
// {
// Type: to.Ptr(armcompute.SharingProfileGroupTypesAADTenants),
// IDs: []*string{
// to.Ptr("c24c76aa-8897-4027-9b03-8f7928b54ff6"),
// },
// },
// },
// },
// },
// 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 retrieves information about a Shared Image Gallery.
*
* @summary retrieves information about a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json
*/
async function getAGalleryWithExpandSharingProfileGroups() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.get("myResourceGroup", "myGalleryName", {
expand: "SharingProfile/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_Get_WithExpandSharingProfileGroups.json
// this example is just showing the usage of "Galleries_Get" 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 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";
GalleryExpand? expand = GalleryExpand.SharingProfileGroups;
NullableResponse<GalleryResource> response = await collection.GetIfExistsAsync(galleryName, expand: expand);
GalleryResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// 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
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_get_with_expand_sharing_profile_groups.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.get(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
)
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.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
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"sharingProfile": {
"permissions": "Groups",
"groups": [
{
"type": "Subscriptions",
"ids": [
"34a4ab42-0d72-47d9-bd1a-aed207386dac",
"380fd389-260b-41aa-bad9-0a83108c370b"
]
},
{
"type": "AADTenants",
"ids": [
"c24c76aa-8897-4027-9b03-8f7928b54ff6"
]
}
]
}
},
"location": "West US",
"name": "myGalleryName"
}
Get a gallery with select permissions.
Sample request
GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03&$select=Permissions&$expand=SharingProfile/Groups
import com.azure.resourcemanager.compute.models.SelectPermissions;
/**
* Samples for Galleries GetByResourceGroup.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithSelectPermissions.json
*/
/**
* Sample code: Get a gallery with select permissions.
*
* @param manager Entry point to ComputeManager.
*/
public static void getAGalleryWithSelectPermissions(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().getByResourceGroupWithResponse("myResourceGroup", "myGalleryName",
SelectPermissions.PERMISSIONS, null, 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/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Get_WithSelectPermissions.json
func ExampleGalleriesClient_Get_getAGalleryWithSelectPermissions() {
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)
}
res, err := clientFactory.NewGalleriesClient().Get(ctx, "myResourceGroup", "myGalleryName", &armcompute.GalleriesClientGetOptions{
Select: to.Ptr(armcompute.SelectPermissionsPermissions)})
if err != nil {
log.Fatalf("failed to finish the request: %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.GalleriesClientGetResponse{
// Gallery: &armcompute.Gallery{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Properties: &armcompute.GalleryProperties{
// SharingProfile: &armcompute.SharingProfile{
// Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesGroups),
// Groups: []*armcompute.SharingProfileGroup{
// {
// Type: to.Ptr(armcompute.SharingProfileGroupTypesSubscriptions),
// IDs: []*string{
// to.Ptr("34a4ab42-0d72-47d9-bd1a-aed207386dac"),
// to.Ptr("380fd389-260b-41aa-bad9-0a83108c370b"),
// },
// },
// {
// Type: to.Ptr(armcompute.SharingProfileGroupTypesAADTenants),
// IDs: []*string{
// to.Ptr("c24c76aa-8897-4027-9b03-8f7928b54ff6"),
// },
// },
// },
// },
// },
// 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 retrieves information about a Shared Image Gallery.
*
* @summary retrieves information about a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithSelectPermissions.json
*/
async function getAGalleryWithSelectPermissions() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.get("myResourceGroup", "myGalleryName", {
select: "Permissions",
});
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_Get_WithSelectPermissions.json
// this example is just showing the usage of "Galleries_Get" 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 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";
SelectPermission? select = SelectPermission.Permissions;
NullableResponse<GalleryResource> response = await collection.GetIfExistsAsync(galleryName, select: select);
GalleryResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// 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
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_get_with_select_permissions.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.get(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
)
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithSelectPermissions.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
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"sharingProfile": {
"permissions": "Groups",
"groups": [
{
"type": "Subscriptions",
"ids": [
"34a4ab42-0d72-47d9-bd1a-aed207386dac",
"380fd389-260b-41aa-bad9-0a83108c370b"
]
},
{
"type": "AADTenants",
"ids": [
"c24c76aa-8897-4027-9b03-8f7928b54ff6"
]
}
]
}
},
"location": "West US",
"name": "myGalleryName"
}
Get a gallery with system-assigned and user-assigned managed identities.
Sample request
GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03&$select=Permissions&$expand=SharingProfile/Groups
/**
* Samples for Galleries GetByResourceGroup.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithManagedIdentity.json
*/
/**
* Sample code: Get a gallery with system-assigned and user-assigned managed identities.
*
* @param manager Entry point to ComputeManager.
*/
public static void getAGalleryWithSystemAssignedAndUserAssignedManagedIdentities(
com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().getByResourceGroupWithResponse("myResourceGroup", "myGalleryName", null,
null, 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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Get_WithManagedIdentity.json
func ExampleGalleriesClient_Get_getAGalleryWithSystemAssignedAndUserAssignedManagedIdentities() {
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)
}
res, err := clientFactory.NewGalleriesClient().Get(ctx, "myResourceGroup", "myGalleryName", nil)
if err != nil {
log.Fatalf("failed to finish the request: %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.GalleriesClientGetResponse{
// 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{
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// },
// },
// Properties: &armcompute.GalleryProperties{
// Description: to.Ptr("This is the gallery description."),
// Identifier: &armcompute.GalleryIdentifier{
// UniqueName: to.Ptr("{subscription-id}-MYGALLERYNAME"),
// },
// ProvisioningState: to.Ptr(armcompute.GalleryProvisioningStateSucceeded),
// },
// 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 retrieves information about a Shared Image Gallery.
*
* @summary retrieves information about a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_WithManagedIdentity.json
*/
async function getAGalleryWithSystemAssignedAndUserAssignedManagedIdentities() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.get("myResourceGroup", "myGalleryName");
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_Get_WithManagedIdentity.json
// this example is just showing the usage of "Galleries_Get" 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 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";
NullableResponse<GalleryResource> response = await collection.GetIfExistsAsync(galleryName);
GalleryResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// 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
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_get_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.get(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
)
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get_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
Sample response
{
"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": {
"principalId": "00000000-0000-0000-0000-000000000000",
"clientId": "00000000-0000-0000-0000-000000000000"
}
}
},
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Succeeded"
},
"location": "West US",
"name": "myGalleryName"
}
Get a gallery.
Sample request
GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2025-03-03&$select=Permissions&$expand=SharingProfile/Groups
/**
* Samples for Galleries GetByResourceGroup.
*/
public final class Main {
/*
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get.json
*/
/**
* Sample code: Get a gallery.
*
* @param manager Entry point to ComputeManager.
*/
public static void getAGallery(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getGalleries().getByResourceGroupWithResponse("myResourceGroup", "myGalleryName", null,
null, 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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-03-03/galleryExamples/Gallery_Get.json
func ExampleGalleriesClient_Get_getAGallery() {
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)
}
res, err := clientFactory.NewGalleriesClient().Get(ctx, "myResourceGroup", "myGalleryName", nil)
if err != nil {
log.Fatalf("failed to finish the request: %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.GalleriesClientGetResponse{
// 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.GalleryProvisioningStateSucceeded),
// },
// 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 retrieves information about a Shared Image Gallery.
*
* @summary retrieves information about a Shared Image Gallery.
* x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get.json
*/
async function getAGallery() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscription-id}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.get("myResourceGroup", "myGalleryName");
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_Get.json
// this example is just showing the usage of "Galleries_Get" 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 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";
NullableResponse<GalleryResource> response = await collection.GetIfExistsAsync(galleryName);
GalleryResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// 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
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python gallery_get.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.get(
resource_group_name="myResourceGroup",
gallery_name="myGalleryName",
)
print(response)
# x-ms-original-file: 2025-03-03/galleryExamples/Gallery_Get.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
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName",
"properties": {
"description": "This is the gallery description.",
"identifier": {
"uniqueName": "{subscription-id}-MYGALLERYNAME"
},
"provisioningState": "Succeeded"
},
"location": "West US",
"name": "myGalleryName"
}
Definitions
ApiError
Object
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
Object
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
Object
An error response from the Compute service.
| Name |
Type |
Description |
|
error
|
ApiError
|
Api error.
|
Common.UserAssignedIdentitiesValue
Object
| Name |
Type |
Description |
|
clientId
|
string
|
The client id of user assigned identity.
|
|
principalId
|
string
|
The principal id of user assigned identity.
|
Object
Information of community gallery if current gallery is shared to community
| Name |
Type |
Description |
|
communityGalleryEnabled
|
boolean
|
Contains info about whether community gallery sharing is enabled.
|
|
eula
|
string
|
End-user license agreement for community gallery image.
|
|
publicNamePrefix
|
string
|
The prefix of the gallery name that will be displayed publicly. Visible to all users.
|
|
publicNames
|
string[]
|
Community gallery public name list.
|
|
publisherContact
|
string
|
Community gallery publisher support email. The email address of the publisher. Visible to all users.
|
|
publisherUri
|
string
|
The link to the publisher website. Visible to all users.
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
Gallery
Object
Specifies information about the Shared Image Gallery that you want to create or update.
| Name |
Type |
Description |
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
identity
|
GalleryIdentity
|
The identity of the gallery, if configured.
|
|
location
|
string
|
The geo-location where the resource lives
|
|
name
|
string
|
The name of the resource
|
|
properties.description
|
string
|
The description of this Shared Image Gallery resource. This property is updatable.
|
|
properties.identifier
|
GalleryIdentifier
|
Describes the gallery unique name.
|
|
properties.provisioningState
|
GalleryProvisioningState
|
The provisioning state, which only appears in the response.
|
|
properties.sharingProfile
|
SharingProfile
|
Profile for gallery sharing to subscription or tenant
|
|
properties.sharingStatus
|
SharingStatus
|
Sharing status of current gallery.
|
|
properties.softDeletePolicy
|
SoftDeletePolicy
|
Contains information about the soft deletion policy of the gallery.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
Resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
GalleryExpandParams
Enumeration
The expand query option to apply on the operation.
| Value |
Description |
|
SharingProfile/Groups
|
|
GalleryIdentifier
Object
Describes the gallery unique name.
| Name |
Type |
Description |
|
uniqueName
|
string
|
The unique name of the Shared Image Gallery. This name is generated automatically by Azure.
|
GalleryIdentity
Object
Identity for the virtual machine.
| Name |
Type |
Description |
|
principalId
|
string
|
The principal id of the gallery identity. This property will only be provided for a system assigned identity.
|
|
tenantId
|
string
|
The AAD tenant id of the gallery identity. This property will only be provided for a system assigned identity.
|
|
type
|
ResourceIdentityType
|
The type of identity used for the gallery. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove all identities from the gallery.
|
|
userAssignedIdentities
|
<string,
Common.UserAssignedIdentitiesValue>
|
The list of user identities associated with the gallery. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
GalleryProvisioningState
Enumeration
The provisioning state, which only appears in the response.
| Value |
Description |
|
Creating
|
|
|
Updating
|
|
|
Failed
|
|
|
Succeeded
|
|
|
Deleting
|
|
|
Migrating
|
|
GallerySharingPermissionTypes
Enumeration
This property allows you to specify the permission of sharing gallery. Possible values are: Private, Groups, Community.
| Value |
Description |
|
Private
|
|
|
Groups
|
|
|
Community
|
|
InnerError
Object
Inner error details.
| Name |
Type |
Description |
|
errordetail
|
string
|
The internal error message or exception dump.
|
|
exceptiontype
|
string
|
The exception type.
|
RegionalSharingStatus
Object
Gallery regional sharing status
| Name |
Type |
Description |
|
details
|
string
|
Details of gallery regional sharing failure.
|
|
region
|
string
|
Region name
|
|
state
|
SharingState
|
Gallery sharing state in current region
|
ResourceIdentityType
Enumeration
The type of identity used for the gallery. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove all identities from the gallery.
| Value |
Description |
|
SystemAssigned
|
|
|
UserAssigned
|
|
|
SystemAssigned, UserAssigned
|
|
|
None
|
|
SelectPermissions
Enumeration
The select expression to apply on the operation.
| Value |
Description |
|
Permissions
|
|
SharingProfile
Object
Profile for gallery sharing to subscription or tenant
| Name |
Type |
Description |
|
communityGalleryInfo
|
CommunityGalleryInfo
|
Information of community gallery if current gallery is shared to community.
|
|
groups
|
SharingProfileGroup[]
|
A list of sharing profile groups.
|
|
permissions
|
GallerySharingPermissionTypes
|
This property allows you to specify the permission of sharing gallery. Possible values are: Private, Groups, Community.
|
SharingProfileGroup
Object
Group of the gallery sharing profile
| Name |
Type |
Description |
|
ids
|
string[]
|
A list of subscription/tenant ids the gallery is aimed to be shared to.
|
|
type
|
SharingProfileGroupTypes
|
This property allows you to specify the type of sharing group. Possible values are: Subscriptions, AADTenants.
|
SharingProfileGroupTypes
Enumeration
This property allows you to specify the type of sharing group. Possible values are: Subscriptions, AADTenants.
| Value |
Description |
|
Subscriptions
|
|
|
AADTenants
|
|
SharingState
Enumeration
The sharing state of the gallery, which only appears in the response.
| Value |
Description |
|
Succeeded
|
|
|
InProgress
|
|
|
Failed
|
|
|
Unknown
|
|
SharingStatus
Object
Sharing status of current gallery.
| Name |
Type |
Description |
|
aggregatedState
|
SharingState
|
Aggregated sharing state of current gallery.
|
|
summary
|
RegionalSharingStatus[]
|
Summary of all regional sharing status.
|
SoftDeletePolicy
Object
Contains information about the soft deletion policy of the gallery.
| Name |
Type |
Description |
|
isSoftDeleteEnabled
|
boolean
|
Enables soft-deletion for resources in this gallery, allowing them to be recovered within retention time.
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|