删除与客户的经销商关系

适用于:合作伙伴中心 | 由世纪互联运营的合作伙伴中心 | Microsoft Cloud for US Government 合作伙伴中心

删除与你不再有交易的客户的经销商关系。

先决条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以在合作伙伴中心查找它。 从合作伙伴中心主页中选择“客户”工作区。 从 “客户”列表中选择客户,然后选择“ 帐户”。 在客户的“帐户”页上,在“客户帐户详细信息”部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。

  • 删除经销商关系之前,必须取消所有 Azure 预留 VM 实例订单。 调用Azure 支持取消任何打开的 Azure 虚拟机预留实例订单。

C#

若要删除客户的经销商关系,请先确保取消该客户的任何活动的 Azure 虚拟机预留实例。 接下来,请确保该客户的所有活动订阅已暂停。 为此,请确定要为其删除经销商关系的客户的 ID。 在以下代码示例中,系统会提示用户提供客户标识符。

若要确定必须取消客户的任何 Azure 虚拟机预留实例,请使用客户标识符调用 IAggregatePartner.Customers.ById 方法来检索权利集合,并使用权利属性检索权利收集操作的接口。 调用 GetGetAsync 方法以检索权利集合。 筛选具有 EntitlementType.VirtualMachineReservedInstance的任何权利集合,如果有,请在继续操作之前通过调用支持来取消它们。

然后,使用客户标识符来调用 IAggregatePartner.Customers.ById 方法来检索客户的订阅集合,并使用订阅属性检索订阅收集操作的接口。 最后,调用 GetGetAsync 方法以检索客户的订阅集合。 遍历订阅集合并确保任何订阅都没有 SubscriptionStatus.ActiveSubscription.Status 属性值。 如果订阅仍然处于活动状态,请参阅 “暂停订阅 ”,了解如何暂停订阅。

确认取消该客户的所有活动 Azure 虚拟机预留实例并暂停所有活动订阅后,可以删除客户的经销商关系。 首先,创建一个新的 Customer 对象,并将 relationshiptopartner 属性设置为 CustomerPartnerRelationship.None。 然后使用客户标识符指定客户并调用 Patch 方法(传入新的客户对象)调用 IAggregatePartner.Customers.ById 方法。

若要重新建立关系,请重复请求经销商关系的过程

// 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");
}

示例控制台测试应用项目:PartnerSDK.FeatureSample :DeletePartnerCustomerRelationship.cs

REST 请求

请求语法

方法 请求 URI
PATCH {baseURL}/v1/customers/{customer-tenant-id}/ HTTP/1.1

URI 参数

下表列出了删除经销商关系所需的查询参数。

名称 类型​​ 必需 说明
customer-tenant-id guid Y 该值是标识客户的 GUID 格式 的客户租户 ID

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求正文

请求正文中需要客户资源。 确保 RelationshipToPartner 属性已设置为 none。

请求示例

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: 9b4bf2ca-f374-4d51-9113-781ca87b8380
MS-RequestId: 9fef8b23-6e3e-45d2-8678-e9fe89c35af5
Date: Fri, 12 Jan 2018 00:31:55 GMT

{
    "relationshipToPartner":"none",
    "attributes":{
        "objectType":"Customer"
    }
}

REST 响应

如果成功,此方法将删除指定客户的经销商关系。

响应的成功和错误代码

每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 如需完整列表,请参阅合作伙伴中心 REST 错误代码

响应示例

HTTP/1.1 200 OK
MS-RequestId: 7988dde4-b516-472c-b226-6d53fb18f04e
MS-CorrelationId: 9b4bf2ca-f374-4d51-9113-781ca87b8380
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"
    }
}