Delete a customer account from the integration sandbox

Applies to: Partner Center | Partner Center operated by 21Vianet | Partner Center for Microsoft Cloud for US Government

This article explains, how to break the relationship between the partner and the customer account and regain the quota for Testing in Production (Tip) integration sandbox.

Important

When you delete a customer account, all resources associated with that customer tenant will be purged.

Prerequisites

  • Credentials as described in Partner Center authentication. This scenario supports authentication with both standalone App and App+User credentials.

  • A customer ID (customer-tenant-id). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer’s Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id).

  • All Azure Reserved Virtual Machine Instances and software purchase orders must be canceled before deleting a customer from the Tip integration sandbox.

C#

To delete a customer from the Tip integration sandbox:

  1. Pass your Tip account credentials to the CreatePartnerOperations method to get an IPartner interface to partner operations.

  2. Use the partner operations interface to retrieve the collection of entitlements:

    1. Call the Customers.ById() method with the customer identifier to specify the customer.

    2. Call the Entitlements property.

    3. Call the Get or GetAsync method to retrieve the Entitlement collection.

  3. Make sure that all Azure Reserved Virtual Machine Instances and software purchase orders for that customer are canceled. For each Entitlement in the collection:

    1. Use the entitlement.ReferenceOrder.Id to get a local copy of the corresponding Order from the customer's collection of orders.

    2. Set the Order.Status property to "Cancelled".

    3. Use the Patch() method to update the order.

  4. Cancel all orders. For example, the following code sample uses a loop to poll each order until its status is "Cancelled".

    // IPartnerCredentials tipAccountCredentials;
    // Customer tenant Id to be deleted.
    // string customerTenantId;
    
    IPartner tipAccountPartnerOperations = PartnerService.Instance.CreatePartnerOperations(tipAccountCredentials);
    
    // Get all entitlements whose order must be canceled.
    ResourceCollection<Entitlement> entitlements = tipAccountPartnerOperations.Customers.ById(customerTenantId).Entitlements.Get();
    
    // Cancel all orders
    foreach (var entitlement in entitlements)
    {
        var order = tipAccountPartnerOperations.Customers.ById(customerTenantId).Orders.ById(entitlement.ReferenceOrder.Id).Get();
        order.Status = "Cancelled";
        order = tipAccountPartnerOperations.Customers.ById(customerTenantId).Orders.ById(order.Id).Patch(order);
    }
    
    // Keep polling until the status of all orders is "Cancelled".
    bool proceed = true;
    do
    {
        // Check if all the orders were canceled.
        foreach (var entitlement in entitlements)
        {
            var order = tipAccountPartnerOperations.Customers.ById(customerTenantId).Orders.ById(entitlement.ReferenceOrder.Id).Get();
            if (!order.Status.Equals("Cancelled", StringComparison.OrdinalIgnoreCase))
            {
                proceed = false;
            }
        }
    
        // Wait for a few seconds.
        Thread.Sleep(5000);
    }
    while (proceed == false);
    
    tipAccountPartnerOperations.Customers.ById(customerTenantId).Delete();
    
  5. Make sure all orders are canceled by calling the Delete method for the customer.

Sample: Console test app. Project: Partner Center PartnerCenterSDK.FeaturesSamples Class: DeleteCustomerFromTipAccount.cs

REST request

Request syntax

Method Request URI
DELETE {baseURL}/v1/customers/{customer-tenant-id} HTTP/1.1

URI parameter

Use the following query parameter to delete a customer.

Name Type Required Description
customer-tenant-id GUID Y The value is a GUID formatted customer-tenant-id that allows the reseller to filter the results for a given customer that belongs to the reseller.

Request headers

For more information, see Partner Center REST headers.

Request body

None.

Request example

DELETE https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id> HTTP/1.1
Accept: application/json
MS-RequestId: 655890ba-4d2b-4d09-a95f-4ea1348686a5
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
Content-Length: 0

REST response

If successful, this method returns an empty response.

Response success and error codes

Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For the full list, see Partner Center REST error codes.

Response example

HTTP/1.1 204 No Content
Content-Length: 0
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 655890ba-4d2b-4d09-a95f-4ea1348686a5
Date: Wed, 16 Mar 2016 00:43:02 GMT