在資源或訂用帳戶上建立或更新整個標籤。
這項作業允許在指定的資源或訂用帳戶上新增或取代整個標籤。 指定的實體最多可以有50個標記。
PUT https://management.azure.com/{scope}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01
URI 參數
名稱 |
位於 |
必要 |
類型 |
Description |
scope
|
path |
True
|
string
|
資源範圍。
|
api-version
|
query |
True
|
string
|
用於此作業的 API 版本。
|
要求本文
名稱 |
必要 |
類型 |
Description |
properties
|
True
|
Tags
|
標記集。
|
回應
安全性
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/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
範例回覆
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
範例要求
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
範例回覆
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
定義
CloudError
資源管理要求的錯誤回應。
名稱 |
類型 |
Description |
error
|
ErrorResponse
|
錯誤回應
所有 Azure Resource Manager API 的常見錯誤回應,以傳回失敗作業的錯誤詳細數據。 (這也會遵循 OData 錯誤回應格式。)
|
ErrorAdditionalInfo
資源管理錯誤其他資訊。
名稱 |
類型 |
Description |
info
|
object
|
其他資訊。
|
type
|
string
|
其他信息類型。
|
ErrorResponse
錯誤回應
名稱和值組的字典。
名稱 |
類型 |
Description |
tags
|
object
|
|
標記 API 要求和回應的包裝函式資源。
名稱 |
類型 |
Description |
id
|
string
|
標記包裝函式資源的標識碼。
|
name
|
string
|
標記包裝函式資源的名稱。
|
properties
|
Tags
|
標記集。
|
type
|
string
|
標記包裝函式資源的型別。
|