Remove a reseller relationship with a customer
Applies to: Partner Center | Partner Center operated by 21Vianet | Partner Center for Microsoft Cloud for US Government
Remove a reseller relationship with a customer that you no longer have transactions with.
Prerequisites
Credentials as described in Partner Center authentication. This scenario supports authentication with App+User credentials only.
A customer ID (
customer-tenant-id
). If you don't know the customer's ID, you can look it up in Partner Center. Select the Customers workspace from the Partner Center Home page. Select the customer from the Customer list, then select Account. On the customer's Account page, look for the Microsoft ID in the Customer Account details section. The Microsoft ID is the same as the customer ID (customer-tenant-id
).All Azure Reserved VM Instance orders must be canceled before a reseller relationship is removed. Call Azure support for canceling any open Azure Reserved VM Instance orders.
C#
To remove the reseller relationship for a customer, first ensure that any active Azure Reserved VM Instances for that customer are canceled. Next, ensure that all active subscriptions for that customer are suspended. To do so, determine the ID of the customer for whom you want to delete the reseller relationship. In the following code example, the user is prompted to provide the customer identifier.
To determine if any Azure Reserved VM Instances for the customer must be canceled, retrieve the collection of entitlements by calling the IAggregatePartner.Customers.ById method using the customer identifier to specify the customer, and the Entitlements property to retrieve an interface to entitlement collection operations. Call the Get or GetAsync method to retrieve the entitlement collection. Filter the collection for any entitlements with an EntitlementType value of EntitlementType.VirtualMachineReservedInstance and if there are any, cancel them by calling support before proceeding.
Then, retrieve a collection of the customer's subscriptions by calling the IAggregatePartner.Customers.ById method using the customer identifier to specify the customer, and the Subscriptions property to retrieve an interface to subscription collection operations. Finally, call the Get or GetAsync method to retrieve the customer's subscriptions collection. Traverse the subscription collection and ensure that none of the subscriptions have a Subscriptions.Status property value of SubscriptionStatus.Active. If a subscription is still active, see Suspend a subscription for information on how to suspend it.
After confirming that all active Azure Reserved VM Instances for that customer are canceled and all active subscriptions are suspended, you can remove the reseller relationship for the customer. First, create a new Customer object with the relationshiptopartner property set to CustomerPartnerRelationship.None. Then call the IAggregatePartner.Customers.ById method using the customer identifier to specify the customer, and call the Patch method, passing in the new customer object.
To re-establish the relationship, repeat the process of requesting a reseller relationship.
// IAggregatePartner partnerOperations;
// Prompt the user the enter the customer ID.
var customerIdToDeleteRelationshipOf = this.Context.ConsoleHelper.ReadNonEmptyString("Please enter the ID of the customer you want to delete the relationship with", "The customer ID can't be empty");
// Determine if there are any active Azure Reserved VM Instances for this customer.
ResourceCollection<Entitlement> entitlements = partnerOperations.Customers.ById(customerIdToDeleteRelationshipOf).Entitlements.Get();
If (entitlements.Items.Where(x => x.EntitlementType == EntitlementType.VirtualMachineReservedInstance).Any())
{
this.Context.ConsoleHelper.Warning("Please cancel Azure Reserved Virtual Machine Instance orders through support and try again. Aborting the delete customer relationship operation");
return;
}
// Verify that there are no active subscriptions.
ResourceCollection<Subscription> customerSubscriptions = partnerOperations.Customers.ById(customerIdToDeleteRelationshipOf).Subscriptions.Get();
IList<Subscription> subscriptions = new List<Subscription>(customerSubscriptions.Items);
foreach (Subscription customerSubscription in subscriptions)
{
if (customerSubscription.Status == SubscriptionStatus.Active)
{
this.Context.ConsoleHelper.Warning(String.Format("Subscription with ID :{0} OfferName: {1} cannot be in active state, ", customerSubscription.Id, customerSubscription.OfferName));
this.Context.ConsoleHelper.Warning("Please Suspend all the Subscriptions and try again. Aborting the delete customer relationship operation");
return;
}
}
// Delete the customer's relationship to the partner.
Customer customer = new Customer();
customer.RelationshipToPartner = CustomerPartnerRelationship.None;
customer = partnerOperations.Customers.ById(customerIdToDeleteRelationshipOf).Patch(customer);
if (customer.RelationshipToPartner == CustomerPartnerRelationship.None)
{
this.Context.ConsoleHelper.Success("Customer Partner Relationship successfully deleted");
}
Sample: Console test app. Project: PartnerSDK.FeatureSample Class: DeletePartnerCustomerRelationship.cs
REST request
Request syntax
Method | Request URI |
---|---|
PATCH | {baseURL}/v1/customers/{customer-tenant-id}/ HTTP/1.1 |
URI parameter
This table lists the required query parameters to remove a reseller relationship.
Name | Type | Required | Description |
---|---|---|---|
customer-tenant-id | guid | Y | The value is a GUID formatted customer-tenant-id that identifies the customer. |
Request headers
For more information, see Partner Center REST headers.
Request body
A Customer resource is required in the request body. Ensure the RelationshipToPartner property has been set to none.
Request example
PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id> HTTP/1.1
Authorization: Bearer <token>
Content-Length: 74
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 9fef8b23-6e3e-45d2-8678-e9fe89c35af5
Date: Fri, 12 Jan 2018 00:31:55 GMT
{
"relationshipToPartner":"none",
"attributes":{
"objectType":"Customer"
}
}
REST response
If successful, this method removes a reseller relationship for the specified customer.
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 200 OK
MS-RequestId: 7988dde4-b516-472c-b226-6d53fb18f04e
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Content-Type: application/json
Content-Length: 242
Expect: 100-continue
{
"Id":null,
"CommerceId":null,
"CompanyProfile":null,
"BillingProfile":null,
"RelationshipToPartner":"none",
"AllowDelegatedAccess":null,
"UserCredentials":null,
"CustomDomains":null,
"AssociatedPartnerId":null,
"Attributes":{
"ObjectType":"Customer"
}
}