The Create Subscription operation creates a subscription with the subscription object provided in the body of the post.

Request

The Create Subscription request may be specified as follows.

Method Request URI HTTP Version

POST

https://admin-management.contoso.net/subscriptions

HTTP/1.1

URI Parameters

None.

Request Headers

The following table describes request headers.

Request Header Description

Content-Type

Required. Set this header to application/xml; charset=utf-8.

Authorization

Required. Specifies the credentials for this request. The value of this header must be set Negotiate <token>.

Request Body

The format for the request body is as follows:

Copy Code
<AzureProvisioningInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.microsoft.com/Azure/ProvisioningAgent/1.0">
	<AccountAdminLiveEmailId>J1B99GN9@XGUHHDNZ.com</AccountAdminLiveEmailId>
	<FriendlyName>MCBZCAF4MWXRYYGKXJDUZDVFJPEPVSM8QZZA7ZW8AS6S3T8AXLX1ZZAJQ7QW61I5</FriendlyName>
	<OfferCategory>D5JZOD6N85A2X3X0D4PAG9OIE1JJC8B1BLZVKB3JH4M11PCC9OY8FLIEQBVY5WL0</OfferCategory>
	<SubscriptionId>fd21fe81-6a21-4a99-8938-e89f6844fc65</SubscriptionId>
	<Status>Active</Status>
</AzureProvisioningInfo>
Important
The order of the elements in the request body is significant. If an element is required, it must appear in the XML in the order shown above.

The following table describes the key elements of the request body:

Element Name

Description

AccountAdminLiveEmailId

The Microsoft email ID associated with the user account on this subscription.

FriendlyName

The name can be used identify the subscription for your tracking purposes.

OfferCategory

Specifies the offer ID associated with the subscription

SubscriptionId

Specifies the subscription ID

Status

Specifies whether the subscription is active

Response

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

The status code is embedded in the response for this operation; if successful, it will be status code 201 (CREATED).

Response Headers

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Header Description

None

None

Response Body

None.

Example

Create a subscription.

Copy Code
public void CreateSubscription(string adminServiceEndpoint, string userId)
{
	HttpClient httpClient = new HttpClient();
	httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BASIC", Convert.ToBase64String(UnicodeEncoding.Unicode.GetBytes("AdminPortal:" + password)))));

	// Create a subscription for the above user account
	string subscriptionEndpoint = adminServiceEndpoint + "subscriptions/";
	var subscriptionInfo = new AzureProvisioningInfo()
	{
		//SubscriptionId = new Guid("35498aa8-1235-6312-bfd6-1237d214aa78"),
		SubscriptionId = Guid.NewGuid(),
		FriendlyName = userId,
		AccountAdminLiveEmailId = userId,
		ServiceAdminLiveEmailId = userId,
		AccountAdminLivePuid = userId,
		ServiceAdminLivePuid = userId,
		OfferCategory = "silveh83g7btb",
};
	Console.WriteLine(httpClient.PostAsXmlAsync<AzureProvisioningInfo>(subscriptionEndpoint, subscriptionInfo).Result.EnsureSuccessStatusCode() + "\n Successfully Created Subscription");
}