Operazione per rinominare una sottoscrizione
POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename?api-version=2021-10-01
Parametri dell'URI
Nome |
In |
Necessario |
Tipo |
Descrizione |
subscriptionId
|
path |
True
|
string
|
ID sottoscrizione.
|
api-version
|
query |
True
|
string
|
Versione dell'API da usare con la richiesta client. La versione corrente è 2021-10-01
|
Corpo della richiesta
Nome |
Tipo |
Descrizione |
subscriptionName
|
string
|
Nuovo nome della sottoscrizione
|
Risposte
Sicurezza
azure_auth
Flusso OAuth2 di Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL di autorizzazione:
https://login.microsoftonline.com/common/oauth2/authorize
Ambiti
Nome |
Descrizione |
user_impersonation
|
rappresentare l'account utente
|
Esempio
renameSubscription
Esempio di richiesta
POST https://management.azure.com/subscriptions/83aa47df-e3e9-49ff-877b-94304bf3d3ad/providers/Microsoft.Subscription/rename?api-version=2021-10-01
{
"subscriptionName": "Test Sub"
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.subscription import SubscriptionClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-subscription
# USAGE
python rename_subscription.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 = SubscriptionClient(
credential=DefaultAzureCredential(),
)
response = client.subscription.rename(
subscription_id="83aa47df-e3e9-49ff-877b-94304bf3d3ad",
body={"subscriptionName": "Test Sub"},
)
print(response)
# x-ms-original-file: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/renameSubscription.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
package armsubscription_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/subscription/armsubscription"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/renameSubscription.json
func ExampleClient_Rename() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsubscription.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewClient().Rename(ctx, "83aa47df-e3e9-49ff-877b-94304bf3d3ad", armsubscription.Name{
SubscriptionName: to.Ptr("Test Sub"),
}, 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.RenamedSubscriptionID = armsubscription.RenamedSubscriptionID{
// SubscriptionID: to.Ptr("83aa47df-e3e9-49ff-877b-94304bf3d3ad"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SubscriptionClient } = require("@azure/arm-subscriptions");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to The operation to rename a subscription
*
* @summary The operation to rename a subscription
* x-ms-original-file: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/renameSubscription.json
*/
async function renameSubscription() {
const subscriptionId = "83aa47df-e3e9-49ff-877b-94304bf3d3ad";
const body = { subscriptionName: "Test Sub" };
const credential = new DefaultAzureCredential();
const client = new SubscriptionClient(credential);
const result = await client.subscriptionOperations.rename(subscriptionId, body);
console.log(result);
}
renameSubscription().catch(console.error);
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Subscription;
using Azure.ResourceManager.Subscription.Models;
// Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/renameSubscription.json
// this example is just showing the usage of "Subscription_Rename" 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 SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "83aa47df-e3e9-49ff-877b-94304bf3d3ad";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation
SubscriptionName body = new SubscriptionName()
{
SubscriptionNameValue = "Test Sub",
};
RenamedSubscriptionId result = await subscriptionResource.RenameSubscriptionAsync(body);
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"subscriptionId": "83aa47df-e3e9-49ff-877b-94304bf3d3ad"
}
Definizioni
Nome |
Descrizione |
ErrorResponse
|
Descrive il formato della risposta di errore.
|
ErrorResponseBody
|
La risposta di errore indica che il servizio non è in grado di elaborare la richiesta in ingresso. Il motivo viene fornito nel messaggio di errore.
|
RenamedSubscriptionId
|
ID delle sottoscrizioni rinominate
|
SubscriptionName
|
Nuovo nome della sottoscrizione.
|
ErrorResponse
Descrive il formato della risposta di errore.
Nome |
Tipo |
Descrizione |
code
|
string
|
Codice di errore
|
message
|
string
|
Messaggio di errore che indica il motivo per cui l'operazione non è riuscita.
|
ErrorResponseBody
La risposta di errore indica che il servizio non è in grado di elaborare la richiesta in ingresso. Il motivo viene fornito nel messaggio di errore.
Nome |
Tipo |
Descrizione |
code
|
string
|
Codice di errore
|
error
|
ErrorResponse
|
Dettagli dell'errore.
|
message
|
string
|
Messaggio di errore che indica il motivo per cui l'operazione non è riuscita.
|
RenamedSubscriptionId
ID delle sottoscrizioni rinominate
Nome |
Tipo |
Descrizione |
subscriptionId
|
string
|
ID delle sottoscrizioni rinominate
|
SubscriptionName
Nuovo nome della sottoscrizione.
Nome |
Tipo |
Descrizione |
subscriptionName
|
string
|
Nuovo nome della sottoscrizione
|