DELETE https://management.azure.com/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/resourceName?api-version=2023-01-31
/**
* Samples for UserAssignedIdentities Delete.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.json
*/
/**
* Sample code: IdentityDelete.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void identityDelete(com.azure.resourcemanager.AzureResourceManager azure) {
azure.identities().manager().serviceClient().getUserAssignedIdentities().deleteWithResponse("rgName",
"resourceName", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.msi import ManagedServiceIdentityClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-msi
# USAGE
python identity_delete.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 = ManagedServiceIdentityClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.user_assigned_identities.delete(
resource_group_name="rgName",
resource_name="resourceName",
)
print(response)
# x-ms-original-file: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.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 armmsi_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/3d7a3848106b831a4a7f46976fe38aa605c4f44d/specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.json
func ExampleUserAssignedIdentitiesClient_Delete() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmsi.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewUserAssignedIdentitiesClient().Delete(ctx, "rgName", "resourceName", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ManagedServiceIdentityClient } = require("@azure/arm-msi");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Deletes the identity.
*
* @summary Deletes the identity.
* x-ms-original-file: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.json
*/
async function identityDelete() {
const subscriptionId = process.env["MSI_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["MSI_RESOURCE_GROUP"] || "rgName";
const resourceName = "resourceName";
const credential = new DefaultAzureCredential();
const client = new ManagedServiceIdentityClient(credential, subscriptionId);
const result = await client.userAssignedIdentities.delete(resourceGroupName, resourceName);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.ManagedServiceIdentities.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.ManagedServiceIdentities;
// Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.json
// this example is just showing the usage of "UserAssignedIdentities_Delete" 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://zcusa.951200.xyz/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 UserAssignedIdentityResource created on azure
// for more information of creating UserAssignedIdentityResource, please refer to the document of UserAssignedIdentityResource
string subscriptionId = "subid";
string resourceGroupName = "rgName";
string resourceName = "resourceName";
ResourceIdentifier userAssignedIdentityResourceId = UserAssignedIdentityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName);
UserAssignedIdentityResource userAssignedIdentity = client.GetUserAssignedIdentityResource(userAssignedIdentityResourceId);
// invoke the operation
await userAssignedIdentity.DeleteAsync(WaitUntil.Completed);
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue