How to add iRule and http profile to a virtual server

Problem this snippet solves:

  1. First do a Simple Post to create a Virtual Server
  2. Then attach the iRule and Http profile to the virtual server

How to use this snippet:

We need to create a Separate json file for Step 1. For step 2 make sure you have the iRule already present in the BIG-IP, else you need to create one.

Code :

curl -k --user admin:admin -H "Accept: application/json" -H "Content-Type:application/json" -X POST -d@ServiceRouting_forHTTP.json | python -m json.tool

Payload file below ServiceRouting_forHTTP.json

    "addressStatus": "yes",
    "autoLasthop": "default",
    "cmpEnabled": "yes",
    "connectionLimit": 0,
    "destination": "/Common/",
    "enabled": true,
    "fullPath": "ServiceRouting_forHTTP",
    "generation": 37093,
    "gtmScore": 0,
    "ipProtocol": "tcp",
    "kind": "tm:ltm:virtual:virtualstate",
    "mask": "",
    "mirror": "disabled",
    "mobileAppTunnel": "disabled",
    "name": "ServiceRouting_forHTTP",
    "nat64": "disabled",
    "policiesReference": {
        "isSubcollection": true,
        "link": "https://localhost/mgmt/tm/ltm/virtual/~Common~ServiceRouting_forHTTP/policies?ver=11.5.3"
    "pool": "/Common/S4HPool",
    "profilesReference": {
        "isSubcollection": true,
        "link": "https://localhost/mgmt/tm/ltm/virtual/~Common~ServiceRouting_forHTTP/profiles?ver=11.5.3"
    "rateLimit": "disabled",
    "rateLimitDstMask": 0,
    "rateLimitMode": "object",
    "rateLimitSrcMask": 0,
    "selfLink": "https://localhost/mgmt/tm/ltm/virtual/ServiceRouting_forHTTP?ver=11.5.3",
    "source": "",
    "sourceAddressTranslation": {
        "type": "automap"
    "sourcePort": "preserve",
    "synCookieStatus": "not-activated",
    "translateAddress": "enabled",
    "translatePort": "enabled",
    "vlansDisabled": true,
    "vsIndex": 32

  Then make a PUT so that we add the HTTP Profile and also the iRule

curl -s -k -u admin:admin -H 'Content-Type: application/json' -X PUT -d '{"profiles":[{"name":"http"},{"name":"tcp"}], "rules": ["/Common/Testing_class"]}' |python -m json.tool

Tested this on version:

Published Jun 26, 2016
Version 1.0

Was this article helpful?

No CommentsBe the first to comment