Create a Subscription for a Notification

 

Applies To: Windows Azure Pack

Used by the Service Management API to notify the resource provider that a subscription to a plan is being created. The supplied Subscription object provides information that can be used by the resource provider to internally process the new subscription.

Request

Replace <NotificationEndpoint> with the endpoint address for the Windows Azure Pack Custom Resource Provider Notification REST API.

Method

Request URI

HTTP version

POST

http://<NotificationEndpoint>/subscriptions

HTTP/1.1

URI Parameters

None.

Request Headers

The following table describes required and optional request headers.

Request header

Description

Authorization: Basic

Required. The basic authorization token.

x-ms-principal-id

Required. The principal identifier.

x-ms-client-request-id

Optional. The client request identifier.

x-ms-client-session-id

Optional. The client session identifier.

x-ms-principal-liveid

Optional. The principal Live identifier.

Request Body

The following table describes the elements of the request body.

Element name

Description

Subscription

The subscription to create. For more information, see Subscription (Notification Endpoint Object).

Response

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

Status Code

Return status code 201 (Created) if the resource provider internal subscription creation is successful. Status code 202 (Accepted) can be returned if the operation is running asynchronously.

For information about status codes, see Status and Error Codes (Windows Azure Pack Service Management).

Response Headers

The response for this operation includes standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Body

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

Element name

Description

Subscription

The new subscription. For more information, see Subscription (Notification Endpoint Object).

Example

The following code example shows a Create Subscription request.

POST https://<NotificationEndpoint>/subscriptions HTTP/1.1
Referer: https://<Computer>:30004/subscriptions
Accept-Language: en-US
x-ms-client-request-id: 4abcdb02-cf03-4b07-a1e1-d43c4fe06a8b-2013-07-25 06:09:39Z
x-ms-client-session-id: be02e255-38de-4e86-9690-b3a3e3037e4c
x-ms-principal-id: <COMPUTER>\Administrator
x-ms-principal-liveid: <COMPUTER>\Administrator
x-ms-request-id: 60668356a6204f269a455cc3f3901a84.2013-07-25T06:09:42.8465532Z
Authorization: Basic <encoded username and password>
Content-Type: application/json; charset=utf-8
Host: <Computer>:30010
Content-Length: 438
Expect: 100-continue
{
  "SubscriptionId": "685a05ed-3a6f-4c3a-b70c-924a1307834f",
  "SubscriptionName": "Hosting Plan One",
  "State": 0,
  "LifecycleState": 0,
  "LastErrorMessage": null,
  "QuotaSettings": [
    {
      "Key": "Editions",
      "Value": "[{\"displayName\":\"Default\",\"groupName\":\"Default\",\"resourceCount\":\"10\",\"resourceSize\":\"1024\",\"resourceSizeLimit\":\"1024\",\"offerEditionId\":\"070913050037\",\"groupType\":null}]"
    }
  ],
  "AdminId": "egghead@contoso.com",
  "CoAdminIds": [

  ]
}

The following code example shows a Create Subscription JSON response.

{
  "SubscriptionId": "685a05ed-3a6f-4c3a-b70c-924a1307834f",
  "SubscriptionName": "Hosting Plan One",
  "State": 0,
  "LifecycleState": 0,
  "LastErrorMessage": null,
  "QuotaSettings": [
    {
      "Key": "Editions",
      "Value": "[{\"displayName\":\"Default\",\"groupName\":\"Default\",\"resourceCount\":\"10\",\"resourceSize\":\"1024\",\"resourceSizeLimit\":\"1024\",\"offerEditionId\":\"070913050037\",\"groupType\":null}]"
    }
  ],
  "AdminId": "egghead@contoso.com",
  "CoAdminIds": [

  ]
}

Remarks

When calling TBD, the Service Management API waits one minute for a response. If no response is received the subscription is marked as being out of synchronization.

Asynchronous operations are supported. If the create operation will take more than a minute to complete, the resource provider can return 202 (Accepted) and set its internal representation of Subscription (Notification Endpoint Object).LifecycleState to Provisioning. Once the resource provider has completed the create operation, it should set its representation of Subscription (Notification Endpoint Object).LifecycleState to Provisioned .The Service Management API will check Subscription (Notification Endpoint Object).LifecycleState for operation completion every 10 seconds using TBD.

See Also

Windows Azure Pack Custom Resource Provider Notification REST API Reference