Membuat atau memperbarui seluruh kumpulan tag pada sumber daya atau langganan.
Operasi ini memungkinkan penambahan atau mengganti seluruh set tag pada sumber daya atau langganan yang ditentukan. Entitas yang ditentukan dapat memiliki maksimal 50 tag.
PUT https://management.azure.com/{scope}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01
Parameter URI
Nama |
Dalam |
Diperlukan |
Jenis |
Deskripsi |
scope
|
path |
True
|
string
|
Cakupan sumber daya.
|
api-version
|
query |
True
|
string
|
Versi API yang digunakan untuk operasi ini.
|
Isi Permintaan
Nama |
Diperlukan |
Jenis |
Deskripsi |
properties
|
True
|
Tags
|
Kumpulan tag.
|
Respons
Nama |
Jenis |
Deskripsi |
200 OK
|
TagsResource
|
Tag berhasil diperbarui. Mengembalikan tag dari objek yang ditentukan.
|
Other Status Codes
|
CloudError
|
Respons kesalahan yang menjelaskan mengapa operasi gagal.
|
Keamanan
azure_auth
Alur OAuth2 Azure Active Directory
Jenis:
oauth2
Alur:
implicit
URL Otorisasi:
https://login.microsoftonline.com/common/oauth2/authorize
Cakupan
Nama |
Deskripsi |
user_impersonation
|
meniru akun pengguna Anda
|
Contoh
Permintaan sampel
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm/providers/Microsoft.Resources/tags/default?api-version=2021-04-01
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
package armresources_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/resources/armresources"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json
func ExampleTagsClient_CreateOrUpdateAtScope_updateTagsOnAResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armresources.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewTagsClient().CreateOrUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", armresources.TagsResource{
Properties: &armresources.Tags{
Tags: map[string]*string{
"tagKey1": to.Ptr("tag-value-1"),
"tagKey2": to.Ptr("tag-value-2"),
},
},
}, 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.TagsResource = armresources.TagsResource{
// Properties: &armresources.Tags{
// Tags: map[string]*string{
// "tagKey1": to.Ptr("tag-value-1"),
// "tagKey2": to.Ptr("tag-value-2"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ResourceManagementClient } = require("@azure/arm-resources");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags.
*
* @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json
*/
async function updateTagsOnAResource() {
const subscriptionId =
process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const scope =
"subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm";
const parameters = {
properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } },
};
const credential = new DefaultAzureCredential();
const client = new ResourceManagementClient(credential, subscriptionId);
const result = await client.tagsOperations.createOrUpdateAtScope(scope, parameters);
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
Respon sampel
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
Permintaan sampel
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Resources/tags/default?api-version=2021-04-01
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
package armresources_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/resources/armresources"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsSubscription.json
func ExampleTagsClient_CreateOrUpdateAtScope_updateTagsOnASubscription() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armresources.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewTagsClient().CreateOrUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armresources.TagsResource{
Properties: &armresources.Tags{
Tags: map[string]*string{
"tagKey1": to.Ptr("tag-value-1"),
"tagKey2": to.Ptr("tag-value-2"),
},
},
}, 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.TagsResource = armresources.TagsResource{
// Properties: &armresources.Tags{
// Tags: map[string]*string{
// "tagKey1": to.Ptr("tag-value-1"),
// "tagKey2": to.Ptr("tag-value-2"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ResourceManagementClient } = require("@azure/arm-resources");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags.
*
* @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsSubscription.json
*/
async function updateTagsOnASubscription() {
const subscriptionId =
process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
const parameters = {
properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } },
};
const credential = new DefaultAzureCredential();
const client = new ResourceManagementClient(credential, subscriptionId);
const result = await client.tagsOperations.createOrUpdateAtScope(scope, parameters);
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
Respon sampel
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
Definisi
Nama |
Deskripsi |
CloudError
|
Respons kesalahan untuk permintaan manajemen sumber daya.
|
ErrorAdditionalInfo
|
Info tambahan kesalahan manajemen sumber daya.
|
ErrorResponse
|
Respons Kesalahan
|
Tags
|
Kamus pasangan nama dan nilai.
|
TagsResource
|
Sumber daya pembungkus untuk tag permintaan dan respons API.
|
CloudError
Respons kesalahan untuk permintaan manajemen sumber daya.
Nama |
Jenis |
Deskripsi |
error
|
ErrorResponse
|
Respons Kesalahan
Respons kesalahan umum untuk semua API Azure Resource Manager untuk mengembalikan detail kesalahan untuk operasi yang gagal. (Ini juga mengikuti format respons kesalahan OData.)
|
ErrorAdditionalInfo
Info tambahan kesalahan manajemen sumber daya.
Nama |
Jenis |
Deskripsi |
info
|
object
|
Info tambahan.
|
type
|
string
|
Jenis info tambahan.
|
ErrorResponse
Respons Kesalahan
Nama |
Jenis |
Deskripsi |
additionalInfo
|
ErrorAdditionalInfo[]
|
Info tambahan kesalahan.
|
code
|
string
|
Kode kesalahan.
|
details
|
ErrorResponse[]
|
Detail kesalahan.
|
message
|
string
|
Pesan kesalahan.
|
target
|
string
|
Target kesalahan.
|
Kamus pasangan nama dan nilai.
Nama |
Jenis |
Deskripsi |
tags
|
object
|
|
Sumber daya pembungkus untuk tag permintaan dan respons API.
Nama |
Jenis |
Deskripsi |
id
|
string
|
ID sumber daya pembungkus tag.
|
name
|
string
|
Nama sumber daya pembungkus tag.
|
properties
|
Tags
|
Kumpulan tag.
|
type
|
string
|
Jenis sumber daya pembungkus tag.
|