Crea o aggiorna l'intero set di tag in una risorsa o una sottoscrizione.
Questa operazione consente di aggiungere o sostituire l'intero set di tag nella risorsa o nella sottoscrizione specificata. L'entità specificata può avere un massimo di 50 tag.
PUT https://management.azure.com/{scope}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01
Parametri dell'URI
Nome |
In |
Necessario |
Tipo |
Descrizione |
scope
|
path |
True
|
string
|
Ambito della risorsa.
|
api-version
|
query |
True
|
string
|
Versione dell'API da usare per questa operazione.
|
Corpo della richiesta
Nome |
Necessario |
Tipo |
Descrizione |
properties
|
True
|
Tags
|
Set di tag.
|
Risposte
Nome |
Tipo |
Descrizione |
200 OK
|
TagsResource
|
Tag aggiornati correttamente. Restituisce tag dall'oggetto specificato.
|
Other Status Codes
|
CloudError
|
Risposta di errore che descrive perché l'operazione non è riuscita.
|
Sicurezza
azure_auth
Flusso OAuth2 di Azure Active Directory
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Nome |
Descrizione |
user_impersonation
|
rappresentare l'account utente
|
Esempio
Sample Request
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
Sample Response
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
Sample Request
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
Sample Response
{
"properties": {
"tags": {
"tagKey1": "tag-value-1",
"tagKey2": "tag-value-2"
}
}
}
Definizioni
Nome |
Descrizione |
CloudError
|
Risposta di errore per una richiesta di gestione delle risorse.
|
ErrorAdditionalInfo
|
Informazioni aggiuntive sulla gestione delle risorse.
|
ErrorResponse
|
Risposta di errore
|
Tags
|
Dizionario di coppie nome e valore.
|
TagsResource
|
Risorsa wrapper per le richieste e le risposte dell'API dei tag.
|
CloudError
Risposta di errore per una richiesta di gestione delle risorse.
Nome |
Tipo |
Descrizione |
error
|
ErrorResponse
|
Risposta di errore
Risposta di errore comune per tutte le API di Resource Manager di Azure per restituire i dettagli degli errori per le operazioni non riuscite. Questo segue anche il formato di risposta di errore OData.
|
ErrorAdditionalInfo
Informazioni aggiuntive sulla gestione delle risorse.
Nome |
Tipo |
Descrizione |
info
|
object
|
Informazioni aggiuntive.
|
type
|
string
|
Tipo di informazioni aggiuntive.
|
ErrorResponse
Risposta di errore
Nome |
Tipo |
Descrizione |
additionalInfo
|
ErrorAdditionalInfo[]
|
Informazioni aggiuntive sull'errore.
|
code
|
string
|
Codice di errore.
|
details
|
ErrorResponse[]
|
Dettagli dell'errore.
|
message
|
string
|
Messaggio di errore.
|
target
|
string
|
Destinazione dell'errore.
|
Dizionario di coppie nome e valore.
Nome |
Tipo |
Descrizione |
tags
|
object
|
|
Risorsa wrapper per le richieste e le risposte dell'API dei tag.
Nome |
Tipo |
Descrizione |
id
|
string
|
ID della risorsa wrapper tag.
|
name
|
string
|
Nome della risorsa wrapper tag.
|
properties
|
Tags
|
Set di tag.
|
type
|
string
|
Tipo della risorsa wrapper tag.
|