合作伙伴中心 - 创建预订 [英] Partner Center - Create reservation
问题描述
我目前正致力于为他创建客户,创建和注册Microsoft Azure订阅的场景,并尝试为该客户创建Azure预留。
以上所有我正在使用沙盒中的合作伙伴中心SDK。
问题是,当我尝试对此订阅进行预订时,我会得到 "订阅:< ID>未注册RI预订"和代码10011无论我使用什么产品。
当我去合作伙伴中心用户界面时,我看不到这个客户的任何天蓝色产品。
我错过了什么吗?
提前致谢。
干杯,
Adam
您好,
以下代码片段供您参考:
public CreateAzureReservationOrder(IScenarioContext context):base("创建Azure预订顺序",上下文)
{
}
///< summary>
///执行方案。
///< / summary>
protected override void RunScenario()
{
var partnerOperations = this.Context.UserPartnerOperations;
string customerId = this.ObtainCustomerId("输入进行购买的客户的ID);
string productId = this.ObtainProductId();
string skuId = this.ObtainSkuId();
string subscriptionId = this.ObtainAzureSubscriptionId();
string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("输入sku的2位国家代码),"国家代码不能为空";);
var sku = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Get();
var availabilitysilities = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Availabilities.Get();
if((sku.DynamicAttributes == null)|| string.IsNullOrEmpty(Convert.ToString(sku.DynamicAttributes [" duration"])))
{
this .Context.ConsoleHelper.Warning("无效的Azure目录项ID。");
}
else
{
if(!availabilitys.Items.Any())
{
this.Context.ConsoleHelper.Warning(" No找到可用性。");
}
其他
{
var order = new Order()
{
ReferenceCustomerId = customerId,
BillingCycle = BillingCycleType.OneTime,
LineItems = new List< OrderLineItem>()
{
new OrderLineItem()
{
OfferId = availabilitysilities.Items.First()。CatalogItemId,
FriendlyName =" ASampleAzureRI",
Quantity = 1,
LineItemNumber = 0,
ProvisioningContext = new Dictionary< string,string>()
{
{" subscriptionId",subscriptionId},
{" scope"," shared" },
{" duration",Convert.ToString(sku.DynamicAttributes [" duration"])}
}
}
}
};
this.Context.ConsoleHelper.WriteObject(order,"Azure Reservation order to put");
this.Context.ConsoleHelper.StartProgress(" Placing order");
var createdOrder = partnerOperations.Customers.ById(customerId).Orders.Create(order);
this.Context.ConsoleHelper.StopProgress();
this.Context.ConsoleHelper.WriteObject(createdOrder,"Created Azure Reservation order");
}
}
}
谢谢
Hi,
I'm currently working on scenario where I create customer, create and register Microsoft Azure subscription for him and I try to create Azure reservation for this customer.
All above I'm doing using Partner Center SDK in sandbox.
Problem is that when I try to make reservation on this subscription I get "Subscription: <ID> is not registered for RI reservations" and code 10011 no matter what product I'm using.
When I go to partner center UI I cannot see any azure products for this customer.
Am I missing something?
Thanks in advance.
Cheers,
Adam
Hi,
The following code snippet for your reference:
public CreateAzureReservationOrder(IScenarioContext context) : base("Create an Azure Reservation order", context) { } /// <summary> /// Executes the scenario. /// </summary> protected override void RunScenario() { var partnerOperations = this.Context.UserPartnerOperations; string customerId = this.ObtainCustomerId("Enter the ID of the customer making the purchase"); string productId = this.ObtainProductId(); string skuId = this.ObtainSkuId(); string subscriptionId = this.ObtainAzureSubscriptionId(); string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the sku", "The country code can't be empty"); var sku = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Get(); var availabilities = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Availabilities.Get(); if ((sku.DynamicAttributes == null) || string.IsNullOrEmpty(Convert.ToString(sku.DynamicAttributes["duration"]))) { this.Context.ConsoleHelper.Warning("Invalid Azure catalog item ID."); } else { if (!availabilities.Items.Any()) { this.Context.ConsoleHelper.Warning("No availabilities found."); } else { var order = new Order() { ReferenceCustomerId = customerId, BillingCycle = BillingCycleType.OneTime, LineItems = new List<OrderLineItem>() { new OrderLineItem() { OfferId = availabilities.Items.First().CatalogItemId, FriendlyName = "ASampleAzureRI", Quantity = 1, LineItemNumber = 0, ProvisioningContext = new Dictionary<string, string>() { { "subscriptionId", subscriptionId }, { "scope", "shared" }, { "duration", Convert.ToString(sku.DynamicAttributes["duration"]) } } } } }; this.Context.ConsoleHelper.WriteObject(order, "Azure Reservation order to be placed"); this.Context.ConsoleHelper.StartProgress("Placing order"); var createdOrder = partnerOperations.Customers.ById(customerId).Orders.Create(order); this.Context.ConsoleHelper.StopProgress(); this.Context.ConsoleHelper.WriteObject(createdOrder, "Created Azure Reservation order"); } } }Partner-Center-SDK-Samples/Source/Partner Center SDK Samples/Orders/CreateAzureReservationOrder.cs
Thanks
这篇关于合作伙伴中心 - 创建预订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!