Create (POST) a Service [SPFSDK][VMMREF]
Applies To: Windows Azure Pack
Creates a Service [SPFSDK][VMMREF] entity by using the HTTP POST operation.
Here is a list of examples related to this collection operation.
- Example: Create a new service from a service template
Request
For more information about the placeholders used in the URI, see URL placeholders.
Method |
Request URI |
HTTP Version |
---|---|---|
POST |
https://{server-name}:{auth-port}/{subscription-id}/services/systemcenter/vmm/Services |
HTTP/1.1 |
Request URI Parameters
This operation does not have any request URI parameters.
Request Headers
This operation does not use any non-standard request headers.
For more information about the common request headers used by this operation, see Common HTTP request information.
Request Body
The request body should contain a single (depending on the request headers) XML or JSON encoded Service [SPFSDK][VMMREF] entity that you want to create. Here is the request body of a single entity with a NewServiceDeployment [SPFSDK][VMMREF] object.
{
"odata.type": "VMM.Service",
"Accessibility": null,
"AddedTime": null,
"AllVMsAccessible": null,
"CloudId": "10f8e459-e7c3-4c40-b47c-b8f758ef4dc1",
"CostCenter": null,
"CustomProperty@odata.type": "Collection(VMM.CustomProperty)",
"CustomProperty": [],
"DeployedTo": null,
"DeploymentState": null,
"Description": null,
"Enabled": null,
"FailedJobID": null,
"GrantedToList@odata.type": "Collection(VMM.UserAndRole)",
"GrantedToList": [],
"ID": "00000000-0000-0000-0000-000000000000",
"IgnorePlacementErrors": null,
"InServicingMode": null,
"ModifiedTime": null,
"Name": null,
"NewServiceDeployment": {
"odata.type": "VMM.NewServiceDeployment",
"ServiceConfiguration": {
"odata.type": "VMM.ServiceDeploymentConfiguration",
"CostCenter": null,
"Description": null,
"Name": "SQL-backed Website",
"Priority": null,
"ServiceSettings@odata.type": "Collection(VMM.ServiceSettingsInput)",
"ServiceSettings": [
{
"Description": null,
"IsEncrypted": null,
"IsRequired": null,
"Name": "WapNetwork",
"Value": "072b4cc6-111b-4755-895b-43f698e03992"
}
],
"Tag": null
},
"TierConfigurations@odata.type": "Collection(VMM.ServiceTierAndVMConfiguration)",
"TierConfigurations": [
{
"Name": "SQL",
"VMConfigurations@odata.type": "Collection(VMM.VMConfiguration)",
"VMConfigurations": [
{
"ComputerName": "SQLServer1",
"CostCenter": null,
"Description": null,
"Tag": null,
"VMName": "SQLServer1"
}
]
},
{
"Name": "Web Frontend",
"VMConfigurations@odata.type": "Collection(VMM.VMConfiguration)",
"VMConfigurations": [
{
"ComputerName": "Website1",
"CostCenter": null,
"Description": null,
"Tag": null,
"VMName": "Website1"
}
]
}
]
},
"NotificationsAvailable": null,
"Operation": null,
"OverallStatus": null,
"Owner": {
"odata.type": "VMM.UserAndRole",
"RoleID": null,
"RoleName": null,
"UserName": null
},
"PendingServiceSettings@odata.type": "Collection(VMM.ServiceSetting)",
"PendingServiceSettings": [],
"PendingServiceTemplatePresent": null,
"PendingServiceTemplateRelease": null,
"ServicePriority": null,
"ServiceSettings@odata.type": "Collection(VMM.ServiceSetting)",
"ServiceSettings": [],
"ServiceStatus": null,
"ServiceTemplateId": "211148d3-b9a0-4bec-bb17-373ba0cd7934",
"ServiceTemplateRelease": null,
"ServicingWindow": {
"odata.type": "VMM.ServicingWindow",
"Category": null,
"DayOfMonth": null,
"DaysToRecur": null,
"Description": null,
"MinutesDuration": null,
"MonthlyScheduleDayOfWeek": null,
"MonthsToRecur": null,
"Name": null,
"Owner": null,
"ScheduleType": null,
"StartDate": null,
"StartTimeOfDay": null,
"TimeZone": null,
"WeeklyScheduleDayOfWeek": null,
"WeekOfMonth": null,
"WeeksToRecur": null
},
"StampId": "d70c1a9b-c241-48f5-880a-b6c36071e653",
"VMHostGroup": null
}
Response
Response Codes
This operation does not return any non-standard OData response codes. If successful, it will return code 201 Created.
Response Headers
This operation does not use any non-standard response headers.
For more information about the common response headers used by this operation, see Common HTTP response information.
Response Body
The response body will contain a single (depending on the request headers) XML or JSON encoded Service [SPFSDK][VMMREF] entity as it exists on the server.
{
"odata.metadata": "https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/$metadata#Services/@Element",
"ID": "16a3df7e-55a6-4edd-b34f-15c712d32b8b",
"Description": "",
"Name": "SQL-backed Website",
"StampId": "d70c1a9b-c241-48f5-880a-b6c36071e653",
"NewServiceDeployment": {
"ServiceConfiguration": {
"ServiceSettings": [
{
"Name": null,
"Value": null,
"Description": null,
"IsRequired": false,
"IsEncrypted": false
}
],
"Name": null,
"Description": null,
"CostCenter": null,
"Tag": null,
"Priority": null
},
"TierConfigurations": [
{
"Name": null,
"VMConfigurations": [
{
"VMName": null,
"ComputerName": null,
"Description": null,
"CostCenter": null,
"Tag": null
}
]
}
]
},
"Owner": {
"UserName": "tenant@fabrikam.com",
"RoleName": "tenant@fabrikam.com_ae122d5f-3aab-4d75-ad48-d6593246a49e",
"RoleID": "ae122d5f-3aab-4d75-ad48-d6593246a49e"
},
"GrantedToList": [],
"AllVMsAccessible": true,
"CostCenter": null,
"DeploymentState": "Deploying",
"DeployedTo": "Cloud",
"InServicingMode": false,
"OverallStatus": "Deploying",
"PendingServiceTemplatePresent": false,
"PendingServiceTemplateRelease": null,
"ServicePriority": "Normal",
"ServiceTemplateRelease": "new",
"ServiceStatus": "OK",
"VMHostGroup": null,
"Enabled": true,
"AddedTime": "2014-08-15T13:14:55.6124193-07:00",
"ModifiedTime": "2014-08-15T13:14:55.8281289-07:00",
"NotificationsAvailable": false,
"Accessibility": "Public",
"Operation": null,
"IgnorePlacementErrors": null,
"FailedJobID": null,
"CloudId": "10f8e459-e7c3-4c40-b47c-b8f758ef4dc1",
"ServiceTemplateId": "211148d3-b9a0-4bec-bb17-373ba0cd7934",
"CustomProperty": [],
"PendingServiceSettings": [],
"ServiceSettings": [
{
"Name": "WapNetwork",
"Description": "",
"Value": "072b4cc6-111b-4755-895b-43f698e03992",
"Mandatory": true,
"HasEncryptedValue": false,
"IsSecure": false,
"GlobalSettingType": "VMNetwork"
}
],
"ServicingWindow": {
"Category": null,
"Name": null,
"Description": null,
"Owner": null,
"TimeZone": null,
"StartDate": null,
"StartTimeOfDay": null,
"WeeklyScheduleDayOfWeek": null,
"MonthlyScheduleDayOfWeek": null,
"DayOfMonth": null,
"WeekOfMonth": null,
"DaysToRecur": null,
"MonthsToRecur": null,
"WeeksToRecur": null,
"MinutesDuration": null,
"ScheduleType": null
}
}
Example: Create a new service from a service template
You create a new service by using a specific service template and then describing the settings of that template. You must know the details of the service template to correctly create a service. The configuration of a service is split into two parts, the service settings (name/value pairs) and the tier configuration. You can determine the service settings you have to configure by inspecting the ServiceSettings property on the ServiceTemplate [SPFSDK][VMMREF] object. However, to configure the tiers and then the virtual machines within those tiers, you must know how the service template is designed. There is no way to use the IaaS service to determine the tier configuration of the service template.
The configuration of a service template is packaged into a NewServiceDeployment [SPFSDK][VMMREF] object, with which you will do these three basic steps.
Create and fill out a ServiceSettingsInput [SPFSDK][VMMREF] object for each setting with the appropriate name and value.
Create and fill out a ServiceTierAndVMConfiguration [SPFSDK][VMMREF] object for each tier in the service.
And then for each tier, create and fill out a VMConfiguration [SPFSDK][VMMREF] object for each virtual machine in the tier.
When you create and submit a Service [SPFSDK][VMMREF] object to the server, set the NewServiceDeployment property to the NewServiceDeployment [SPFSDK][VMMREF] object you have previously created. The example below demonstrates how to create a service from a template.
For more information about how to get started with using the code examples provided in this programming guide, see Program in Visual Studio with the Windows Azure Pack IaaS Resource Provider [SPFSDK].
var service = new WapIaas.Tenant.Service();
service.StampId = new Guid("d70c1a9b-c241-48f5-880a-b6c36071e653");
service.CloudId = new Guid("10f8e459-e7c3-4c40-b47c-b8f758ef4dc1");
var deployment = new WapIaas.Tenant.NewServiceDeployment();
// Setup the service
deployment.ServiceConfiguration = new Tenant.ServiceDeploymentConfiguration();
deployment.ServiceConfiguration.Name = "SQL-backed Website";
// Configure the settings for the service config
{
// Our template has a single setting, named WapNetwork which maps the VMNetwork to the network adapters of the vm.
var settingNetwork = new WapIaas.Tenant.ServiceSettingsInput();
settingNetwork.Name = "WapNetwork";
settingNetwork.Value = "072b4cc6-111b-4755-895b-43f698e03992"; // Guid of our VM network
// Add the setting
deployment.ServiceConfiguration.ServiceSettings.Add(settingNetwork);
}
// Configure the VMs. Our template has two VMs named SQL and Web Frontend.
{
var vmTier1 = new WapIaas.Tenant.ServiceTierAndVMConfiguration();
vmTier1.Name = "SQL";
{
// Configure the single VM for this tier
var vmConfig = new WapIaas.Tenant.VMConfiguration();
vmConfig.ComputerName = "SQLServer1";
vmConfig.VMName = "SQLServer1";
vmTier1.VMConfigurations.Add(vmConfig);
}
// Configure the second tier with a vm.
var vmTier2 = new WapIaas.Tenant.ServiceTierAndVMConfiguration();
vmTier2.Name = "Web Frontend";
{
// Configure the single VM for this tier
var vmConfig = new WapIaas.Tenant.VMConfiguration();
vmConfig.ComputerName = "Website1";
vmConfig.VMName = "Website1";
vmTier2.VMConfigurations.Add(vmConfig);
}
// Add both tiers to the service config.
deployment.TierConfigurations.Add(vmTier1);
deployment.TierConfigurations.Add(vmTier2);
}
// Configuration of the service deployment is finished.
// Set the deployment object and the service template the deployment object represents
service.NewServiceDeployment = deployment;
service.ServiceTemplateId = new Guid("211148d3-b9a0-4bec-bb17-373ba0cd7934");
// Submit the service for creation
vmmService.AddToServices(service);
vmmService.SaveChanges();
HTTP Request
POST https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/Services HTTP/1.1
DataServiceVersion: 3.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Content-Type: application/json;odata=minimalmetadata
Accept: application/json;odata=minimalmetadata
Accept-Charset: UTF-8
DataServiceUrlConventions: KeyAsSegment
User-Agent: Microsoft ADO.NET Data Services
Authorization: Bearer {ENCODED AUTHENTICATION TOKEN}
x-ms-principal-id: tenant@fabrikam.com
Host: contoso.com:30005
Content-Length: 2472
Expect: 100-continue
{"odata.type":"VMM.Service","Accessibility":null,"AddedTime":null,"AllVMsAccessible":null,"CloudId":"10f8e459-e7c3-4c40-b47c-b8f758ef4dc1","CostCenter":null,"CustomProperty@odata.type":"Collection(VMM.CustomProperty)","CustomProperty":[],"DeployedTo":null,"DeploymentState":null,"Description":null,"Enabled":null,"FailedJobID":null,"GrantedToList@odata.type":"Collection(VMM.UserAndRole)","GrantedToList":[],"ID":"00000000-0000-0000-0000-000000000000","IgnorePlacementErrors":null,"InServicingMode":null,"ModifiedTime":null,"Name":null,"NewServiceDeployment":{"odata.type":"VMM.NewServiceDeployment","ServiceConfiguration":{"odata.type":"VMM.ServiceDeploymentConfiguration","CostCenter":null,"Description":null,"Name":"SQL-backed Website","Priority":null,"ServiceSettings@odata.type":"Collection(VMM.ServiceSettingsInput)","ServiceSettings":[{"Description":null,"IsEncrypted":null,"IsRequired":null,"Name":"WapNetwork","Value":"072b4cc6-111b-4755-895b-43f698e03992"}],"Tag":null},"TierConfigurations@odata.type":"Collection(VMM.ServiceTierAndVMConfiguration)","TierConfigurations":[{"Name":"SQL","VMConfigurations@odata.type":"Collection(VMM.VMConfiguration)","VMConfigurations":[{"ComputerName":"SQLServer1","CostCenter":null,"Description":null,"Tag":null,"VMName":"SQLServer1"}]},{"Name":"Web Frontend","VMConfigurations@odata.type":"Collection(VMM.VMConfiguration)","VMConfigurations":[{"ComputerName":"Website1","CostCenter":null,"Description":null,"Tag":null,"VMName":"Website1"}]}]},"NotificationsAvailable":null,"Operation":null,"OverallStatus":null,"Owner":{"odata.type":"VMM.UserAndRole","RoleID":null,"RoleName":null,"UserName":null},"PendingServiceSettings@odata.type":"Collection(VMM.ServiceSetting)","PendingServiceSettings":[],"PendingServiceTemplatePresent":null,"PendingServiceTemplateRelease":null,"ServicePriority":null,"ServiceSettings@odata.type":"Collection(VMM.ServiceSetting)","ServiceSettings":[],"ServiceStatus":null,"ServiceTemplateId":"211148d3-b9a0-4bec-bb17-373ba0cd7934","ServiceTemplateRelease":null,"ServicingWindow":{"odata.type":"VMM.ServicingWindow","Category":null,"DayOfMonth":null,"DaysToRecur":null,"Description":null,"MinutesDuration":null,"MonthlyScheduleDayOfWeek":null,"MonthsToRecur":null,"Name":null,"Owner":null,"ScheduleType":null,"StartDate":null,"StartTimeOfDay":null,"TimeZone":null,"WeeklyScheduleDayOfWeek":null,"WeekOfMonth":null,"WeeksToRecur":null},"StampId":"d70c1a9b-c241-48f5-880a-b6c36071e653","VMHostGroup":null}
HTTP Response
HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 2075
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8
Location: https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/Services(ID=guid'16a3df7e-55a6-4edd-b34f-15c712d32b8b',StampId=guid'd70c1a9b-c241-48f5-880a-b6c36071e653')
Server: Microsoft-IIS/8.5
x-ms-request-id: 61e59548-0dd1-4fc4-9298-35babf99a240
X-Content-Type-Options: nosniff
request-id: d3df681c-b278-0000-98c2-e0d378b2cf01
DataServiceVersion: 3.0;
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
Date: Fri, 15 Aug 2014 20:14:55 GMT
{"odata.metadata":"https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/$metadata#Services/@Element","ID":"16a3df7e-55a6-4edd-b34f-15c712d32b8b","Description":"","Name":"SQL-backed Website","StampId":"d70c1a9b-c241-48f5-880a-b6c36071e653","NewServiceDeployment":{"ServiceConfiguration":{"ServiceSettings":[{"Name":null,"Value":null,"Description":null,"IsRequired":false,"IsEncrypted":false}],"Name":null,"Description":null,"CostCenter":null,"Tag":null,"Priority":null},"TierConfigurations":[{"Name":null,"VMConfigurations":[{"VMName":null,"ComputerName":null,"Description":null,"CostCenter":null,"Tag":null}]}]},"Owner":{"UserName":"tenant@fabrikam.com","RoleName":"tenant@fabrikam.com_ae122d5f-3aab-4d75-ad48-d6593246a49e","RoleID":"ae122d5f-3aab-4d75-ad48-d6593246a49e"},"GrantedToList":[],"AllVMsAccessible":true,"CostCenter":null,"DeploymentState":"Deploying","DeployedTo":"Cloud","InServicingMode":false,"OverallStatus":"Deploying","PendingServiceTemplatePresent":false,"PendingServiceTemplateRelease":null,"ServicePriority":"Normal","ServiceTemplateRelease":"new","ServiceStatus":"OK","VMHostGroup":null,"Enabled":true,"AddedTime":"2014-08-15T13:14:55.6124193-07:00","ModifiedTime":"2014-08-15T13:14:55.8281289-07:00","NotificationsAvailable":false,"Accessibility":"Public","Operation":null,"IgnorePlacementErrors":null,"FailedJobID":null,"CloudId":"10f8e459-e7c3-4c40-b47c-b8f758ef4dc1","ServiceTemplateId":"211148d3-b9a0-4bec-bb17-373ba0cd7934","CustomProperty":[],"PendingServiceSettings":[],"ServiceSettings":[{"Name":"WapNetwork","Description":"","Value":"072b4cc6-111b-4755-895b-43f698e03992","Mandatory":true,"HasEncryptedValue":false,"IsSecure":false,"GlobalSettingType":"VMNetwork"}],"ServicingWindow":{"Category":null,"Name":null,"Description":null,"Owner":null,"TimeZone":null,"StartDate":null,"StartTimeOfDay":null,"WeeklyScheduleDayOfWeek":null,"MonthlyScheduleDayOfWeek":null,"DayOfMonth":null,"WeekOfMonth":null,"DaysToRecur":null,"MonthsToRecur":null,"WeeksToRecur":null,"MinutesDuration":null,"ScheduleType":null}}
See Also
Services Collection [SPFSDK][VMMREF]
Service [SPFSDK][VMMREF]
Read (GET) a Service [SPFSDK][VMMREF]
Update (PUT) a Service [SPFSDK][VMMREF]
Delete (DELETE) a Service [SPFSDK][VMMREF]