建立或更新共用映像庫。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}?api-version=2024-03-03
URI 參數
名稱 |
位於 |
必要 |
類型 |
Description |
galleryName
|
path |
True
|
string
|
共用映像庫的名稱。 允許的字元是字母和數位,中間允許點和句點。 最大長度為80個字元。
|
resourceGroupName
|
path |
True
|
string
|
資源群組的名稱。
|
subscriptionId
|
path |
True
|
string
|
可唯一識別Microsoft Azure 訂用帳戶的訂用帳戶認證。 訂用帳戶標識碼會形成每個服務呼叫 URI 的一部分。
|
api-version
|
query |
True
|
string
|
用戶端 API 版本。
|
要求本文
名稱 |
必要 |
類型 |
Description |
location
|
True
|
string
|
資源位置
|
identity
|
|
GalleryIdentity
|
如果已設定,則為資源庫的身分識別。
|
properties.description
|
|
string
|
此共用映像庫資源的描述。 這個屬性是可更新的。
|
properties.identifier
|
|
GalleryIdentifier
|
描述資源庫的唯一名稱。
|
properties.sharingProfile
|
|
SharingProfile
|
資源庫共用至訂用帳戶或租使用者的配置檔
|
properties.softDeletePolicy
|
|
SoftDeletePolicy
|
包含資源庫虛刪除原則的相關信息。
|
tags
|
|
object
|
資源標籤
|
回應
安全性
azure_auth
Azure Active Directory OAuth2 Flow
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
名稱 |
Description |
user_impersonation
|
模擬您的用戶帳戶
|
範例
範例要求
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2024-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:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* CommunityGallery_Create.json
*/
/**
* Sample code: Create a community gallery.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createACommunityGallery(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().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
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/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{
CommunityGalleryInfo: &armcompute.CommunityGalleryInfo{
Eula: to.Ptr("eula"),
PublicNamePrefix: to.Ptr("PirPublic"),
PublisherContact: to.Ptr("pir@microsoft.com"),
PublisherURI: to.Ptr("uri"),
},
Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesCommunity),
},
},
}, 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.Gallery = armcompute.Gallery{
// Name: to.Ptr("myGalleryName"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Location: to.Ptr("West US"),
// 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{
// CommunityGalleryInfo: &armcompute.CommunityGalleryInfo{
// Eula: to.Ptr("eula"),
// PublicNamePrefix: to.Ptr("PirPublic"),
// PublisherContact: to.Ptr("pir@microsoft.com"),
// PublisherURI: to.Ptr("uri"),
// },
// Permissions: to.Ptr(armcompute.GallerySharingPermissionTypesCommunity),
// },
// },
// }
}
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: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/CommunityGallery_Create.json
*/
async function createACommunityGallery() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const gallery = {
description: "This is the gallery description.",
location: "West US",
sharingProfile: {
communityGalleryInfo: {
eula: "eula",
publicNamePrefix: "PirPublic",
publisherContact: "pir@microsoft.com",
publisherUri: "uri",
},
permissions: "Community",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
gallery,
);
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
範例回覆
{
"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.
範例要求
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2024-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:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* Gallery_Create_WithSharingProfile.json
*/
/**
* Sample code: Create or update a simple gallery with sharing profile.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateASimpleGalleryWithSharingProfile(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().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
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/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.Gallery = armcompute.Gallery{
// Name: to.Ptr("myGalleryName"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Location: to.Ptr("West US"),
// 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.GallerySharingPermissionTypesGroups),
// },
// },
// }
}
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: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/Gallery_Create_WithSharingProfile.json
*/
async function createOrUpdateASimpleGalleryWithSharingProfile() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const gallery = {
description: "This is the gallery description.",
location: "West US",
sharingProfile: { permissions: "Groups" },
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
gallery,
);
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
範例回覆
{
"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.
範例要求
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2024-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:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* Gallery_Create_SoftDeletionEnabled.json
*/
/**
* Sample code: Create or update a simple gallery with soft deletion enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateASimpleGalleryWithSoftDeletionEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().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
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/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.Gallery = armcompute.Gallery{
// Name: to.Ptr("myGalleryName"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Location: to.Ptr("West US"),
// 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),
// SoftDeletePolicy: &armcompute.SoftDeletePolicy{
// IsSoftDeleteEnabled: to.Ptr(true),
// },
// },
// }
}
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: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/Gallery_Create_SoftDeletionEnabled.json
*/
async function createOrUpdateASimpleGalleryWithSoftDeletionEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const gallery = {
description: "This is the gallery description.",
location: "West US",
softDeletePolicy: { isSoftDeleteEnabled: true },
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
gallery,
);
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
範例回覆
{
"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.
範例要求
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2024-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:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* Gallery_Create_WithManagedIdentity.json
*/
/**
* Sample code: Create or update a simple gallery with system-assigned and user-assigned managed identities.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGalleryWithSystemAssignedAndUserAssignedManagedIdentities(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().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
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/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.Gallery = armcompute.Gallery{
// Name: to.Ptr("myGalleryName"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName"),
// Location: to.Ptr("West US"),
// 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.GalleryProvisioningStateSucceeded),
// },
// }
}
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: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/Gallery_Create_WithManagedIdentity.json
*/
async function createOrUpdateASimpleGalleryWithSystemAssignedAndUserAssignedManagedIdentities() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const gallery = {
description: "This is the gallery description.",
identity: {
type: "SystemAssigned, UserAssigned",
userAssignedIdentities: {
"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/myIdentity":
{},
},
},
location: "West US",
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
gallery,
);
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
範例回覆
{
"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.
範例要求
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName?api-version=2024-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:
* specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/
* Gallery_Create.json
*/
/**
* Sample code: Create or update a simple gallery.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateASimpleGallery(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().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
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/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.Gallery = armcompute.Gallery{
// Name: to.Ptr("myGalleryName"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGallery"),
// Location: to.Ptr("West US"),
// 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),
// },
// }
}
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: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2024-03-03/examples/galleryExamples/Gallery_Create.json
*/
async function createOrUpdateASimpleGallery() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const galleryName = "myGalleryName";
const gallery = {
description: "This is the gallery description.",
location: "West US",
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.galleries.beginCreateOrUpdateAndWait(
resourceGroupName,
galleryName,
gallery,
);
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
範例回覆
{
"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"
}
定義
ApiError
Api 錯誤。
名稱 |
類型 |
Description |
code
|
string
|
錯誤碼。
|
details
|
ApiErrorBase[]
|
Api 錯誤詳細數據
|
innererror
|
InnerError
|
Api 內部錯誤
|
message
|
string
|
錯誤訊息。
|
target
|
string
|
特定錯誤的目標。
|
ApiErrorBase
API 錯誤基底。
名稱 |
類型 |
Description |
code
|
string
|
錯誤碼。
|
message
|
string
|
錯誤訊息。
|
target
|
string
|
特定錯誤的目標。
|
CloudError
來自計算服務的錯誤回應。
名稱 |
類型 |
Description |
error
|
ApiError
|
Api 錯誤。
|
如果目前資源庫共用給社群,則社群資源庫的資訊
名稱 |
類型 |
Description |
communityGalleryEnabled
|
boolean
|
包含是否啟用社群資源庫共用的相關信息。
|
eula
|
string
|
社群資源庫映像的使用者許可協定。
|
publicNamePrefix
|
string
|
將公開顯示之資源庫名稱的前置詞。 所有使用者都能看見。
|
publicNames
|
string[]
|
社群資源庫公用名稱清單。
|
publisherContact
|
string
|
社群資源庫發行者支持電子郵件。 發行者的電子郵件位址。 所有使用者都能看見。
|
publisherUri
|
string
|
發行者網站的連結。 所有使用者都能看見。
|
Gallery
指定您要建立或更新之共用映像庫的相關信息。
名稱 |
類型 |
Description |
id
|
string
|
資源標識碼
|
identity
|
GalleryIdentity
|
如果已設定,則為資源庫的身分識別。
|
location
|
string
|
資源位置
|
name
|
string
|
資源名稱
|
properties.description
|
string
|
此共用映像庫資源的描述。 這個屬性是可更新的。
|
properties.identifier
|
GalleryIdentifier
|
描述資源庫的唯一名稱。
|
properties.provisioningState
|
GalleryProvisioningState
|
資源庫或資源庫成品的目前狀態。
只出現在回應中的布建狀態。
|
properties.sharingProfile
|
SharingProfile
|
資源庫共用至訂用帳戶或租使用者的配置檔
|
properties.sharingStatus
|
SharingStatus
|
目前資源庫的共享狀態。
|
properties.softDeletePolicy
|
SoftDeletePolicy
|
包含資源庫虛刪除原則的相關信息。
|
tags
|
object
|
資源標籤
|
type
|
string
|
資源類型
|
GalleryIdentifier
描述資源庫的唯一名稱。
名稱 |
類型 |
Description |
uniqueName
|
string
|
共用映像庫的唯一名稱。 Azure 會自動產生此名稱。
|
GalleryIdentity
虛擬機的身分識別。
名稱 |
類型 |
Description |
principalId
|
string
|
資源庫身分識別的主體標識碼。 此屬性只會針對系統指派的身分識別提供。
|
tenantId
|
string
|
資源庫身分識別的 AAD 租使用者標識碼。 此屬性只會針對系統指派的身分識別提供。
|
type
|
ResourceIdentityType
|
用於資源庫的身分識別類型。 類型 'SystemAssigned, UserAssigned' 包含隱含建立的身分識別和一組使用者指派的身分識別。 類型 『None』 會從資源庫移除所有身分識別。
|
userAssignedIdentities
|
UserAssignedIdentities
|
與資源庫相關聯的使用者身分識別清單。 使用者身分識別字典索引鍵參考的格式為 ARM 資源標識符:'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'。
|
GalleryProvisioningState
資源庫或資源庫成品的目前狀態。
名稱 |
類型 |
Description |
Creating
|
string
|
|
Deleting
|
string
|
|
Failed
|
string
|
|
Migrating
|
string
|
|
Succeeded
|
string
|
|
Updating
|
string
|
|
GallerySharingPermissionTypes
這個屬性可讓您指定共用資源庫的許可權。 可能的值為:Private、Groups、Community。
名稱 |
類型 |
Description |
Community
|
string
|
|
Groups
|
string
|
|
Private
|
string
|
|
InnerError
內部錯誤詳細數據。
名稱 |
類型 |
Description |
errordetail
|
string
|
內部錯誤訊息或例外狀況傾印。
|
exceptiontype
|
string
|
例外狀況類型。
|
RegionalSharingStatus
資源庫區域共享狀態
名稱 |
類型 |
Description |
details
|
string
|
資源庫區域共用失敗的詳細數據。
|
region
|
string
|
區域名稱
|
state
|
SharingState
|
資源庫的共享狀態。
目前區域中的資源庫共享狀態
|
ResourceIdentityType
用於資源庫的身分識別類型。 類型 'SystemAssigned, UserAssigned' 包含隱含建立的身分識別和一組使用者指派的身分識別。 類型 『None』 會從資源庫移除所有身分識別。
名稱 |
類型 |
Description |
None
|
string
|
|
SystemAssigned
|
string
|
|
SystemAssigned, UserAssigned
|
string
|
|
UserAssigned
|
string
|
|
SharingProfile
資源庫共用至訂用帳戶或租使用者的配置檔
SharingProfileGroup
資源庫共用配置檔的群組
名稱 |
類型 |
Description |
ids
|
string[]
|
資源庫的目標訂用帳戶/租使用者標識符清單。
|
type
|
SharingProfileGroupTypes
|
這個屬性可讓您指定共用群組的類型。 可能的值為:訂用帳戶,AADTenants。
|
SharingProfileGroupTypes
這個屬性可讓您指定共用群組的類型。 可能的值為:訂用帳戶,AADTenants。
名稱 |
類型 |
Description |
AADTenants
|
string
|
|
Subscriptions
|
string
|
|
SharingState
資源庫的共享狀態。
名稱 |
類型 |
Description |
Failed
|
string
|
|
InProgress
|
string
|
|
Succeeded
|
string
|
|
Unknown
|
string
|
|
SharingStatus
目前資源庫的共享狀態。
SoftDeletePolicy
包含資源庫虛刪除原則的相關信息。
名稱 |
類型 |
Description |
isSoftDeleteEnabled
|
boolean
|
針對此資源庫中的資源啟用虛刪除功能,使其可在保留時間內復原。
|
UserAssignedIdentities
與虛擬機相關聯的使用者身分識別清單。 使用者身分識別字典索引鍵參考的格式為 ARM 資源標識符:'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'。