Create (POST) a NATRule [SPFSDK][VMMREF]
Applies To: Windows Azure Pack
Create a NATRule [SPFSDK][VMMREF] entity by using the HTTP POST operation.
Here is a list of examples related to this collection operation.
- Example: Create a new NAT connection rule
Request
For more information about the placeholders used in the URI, see URL placeholders.
Method |
Request URI |
HTTP Version |
---|---|---|
POST |
https://{server}:{auth-port}/{subscription-id}/services/systemcenter/vmm/NATRules |
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 NATRule [SPFSDK][VMMREF] entity that you want to create. Here is the request body of a single entity.
{
"odata.type":"VMM.NATRule",
"ExternalIPAddress":null,
"ExternalPort":25015,
"ID":"00000000-0000-0000-0000-000000000000",
"InternalIPAddress":"10.0.0.169",
"InternalPort":25015,
"Name":"Fun Port Rule",
"NATConnectionId":"cc002ebd-acc5-4ae6-9254-010707a55d57",
"Protocol":null,
"StampId":"56ebc6dc-f63c-46e2-8438-2967e0ad83bc"
}
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 NATRule [SPFSDK][VMMREF] entity as it exists on the server.
{
"odata.metadata":"https://contoso.com:30005/86e93b7f-25e3-4c44-8ca1-3ebdbd2dfc06/services/systemcenter/vmm/$metadata#NATRules/@Element",
"StampId":"56ebc6dc-f63c-46e2-8438-2967e0ad83bc",
"ID":"12414468-3cee-4fe4-b0c9-e3db5767ab87",
"NATConnectionId":null,
"Name":"Fun Port Rule",
"ExternalIPAddress":"192.168.0.31",
"ExternalPort":25015,
"InternalIPAddress":"10.0.0.169",
"InternalPort":25015,
"Protocol":"TCP"
}
Example: Create a new NAT connection rule
This example demonstrates how to create a NAT rule for a NAT connection.
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].
Guid stampId = new Guid("56ebc6dc-f63c-46e2-8438-2967e0ad83bc");
Guid natConnectionId = new Guid("cc002ebd-acc5-4ae6-9254-010707a55d57");
var natRule = new SpfVMM.NATRule();
natRule.StampId = stampId;
natRule.NATConnectionId = natConnectionId;
natRule.InternalIPAddress = "10.0.0.169";
natRule.InternalPort = 25015;
natRule.ExternalPort = 25015;
natRule.Name = "Fun Port Rule";
vmmService.AddToNATRules(natRule);
vmmService.SaveChanges();
HTTP Request
POST https://contoso.com:30005/86e93b7f-25e3-4c44-8ca1-3ebdbd2dfc06/services/systemcenter/vmm/NATRules 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: 317
Expect: 100-continue
{"odata.type":"VMM.NATRule","ExternalIPAddress":null,"ExternalPort":25015,"ID":"00000000-0000-0000-0000-000000000000","InternalIPAddress":"10.0.0.169","InternalPort":25015,"Name":"Fun Port Rule","NATConnectionId":"cc002ebd-acc5-4ae6-9254-010707a55d57","Protocol":null,"StampId":"56ebc6dc-f63c-46e2-8438-2967e0ad83bc"}
HTTP Response
HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 409
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8
Location: https://contoso.com:30005/86e93b7f-25e3-4c44-8ca1-3ebdbd2dfc06/services/systemcenter/vmm/NATRules(ID=guid'12414468-3cee-4fe4-b0c9-e3db5767ab87',StampId=guid'56ebc6dc-f63c-46e2-8438-2967e0ad83bc')
Server: Microsoft-IIS/8.5
x-ms-request-id: 4143b2c3-08a0-420d-95ca-78185c40079c
X-Content-Type-Options: nosniff
request-id: 5fbd8ef2-63e6-0000-19b5-bf5fe663cf01
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: Thu, 15 May 2014 22:27:25 GMT
{"odata.metadata":"https://contoso.com:30005/86e93b7f-25e3-4c44-8ca1-3ebdbd2dfc06/services/systemcenter/vmm/$metadata#NATRules/@Element","StampId":"56ebc6dc-f63c-46e2-8438-2967e0ad83bc","ID":"12414468-3cee-4fe4-b0c9-e3db5767ab87","NATConnectionId":null,"Name":"Fun Port Rule","ExternalIPAddress":"192.168.0.31","ExternalPort":25015,"InternalIPAddress":"10.0.0.169","InternalPort":25015,"Protocol":"TCP"}
See Also
NATRules Collection [SPFSDK][VMMREF]
NATRule [SPFSDK][VMMREF]
Read (GET) a NATRule [SPFSDK][VMMREF]
Delete (DELETE) a NATRule [SPFSDK][VMMREF]