Example declarations

The following examples show you some BIG-IP AS3 declarations and the BIG-IP LTM objects they create.

For many more example declarations, see Additional Declarations (you can also see all BIG-IP AS3 properties in one declaration in Declaration using all BIG-IP AS3 Properties).

If you missed it, we recommend you first read Composing a BIG-IP AS3 Declaration for a breakdown of some of the components of a declaration.

Note: If you do not specify certain parameters in your declaration, the system supplies default values. For example, if you do not specify a persistence method (or specify none), the system uses Cookie persistence by default.

Important

Most of the example declarations have been updated in the documentation for BIG-IP AS3 3.20 to remove any template that was specified, and rename any virtual services that used the name serviceMain to service. In BIG-IP AS3 3.20, the generic template is the default, which allows services to use any name.

This also means that many of these declarations on a version prior to 3.20 they will fail unless you add a template. See this FAQ entry and this Troubleshooting entry for more information.

Example 1: Simple HTTP application

Example 1 is the same declaration as in the Composing the Declaration section, though here you can see the system-supplied default values in the second code block. This example creates the following objects on the BIG-IP:

  • Partition (tenant) named Sample_01.
  • Virtual server (HTTP) named service.
  • Pool named web_pool with 2 members monitored by the default HTTP health monitor.
{
   "class": "AS3",
   "action": "deploy",
   "persist": true,
   "declaration": {
      "class": "ADC",
      "schemaVersion": "3.0.0",
      "id": "urn:uuid:33045210-3ab8-4636-9b2a-c98d22ab915d",
      "label": "Sample 1",
      "remark": "Simple HTTP application with RR pool",
      "Sample_01": {
         "class": "Tenant",
         "A1": {
            "class": "Application",
            "service": {
               "class": "Service_HTTP",
               "virtualAddresses": [
                  "10.0.1.10"
               ],
               "pool": "web_pool"
            },
            "web_pool": {
               "class": "Pool",
               "monitors": [
                  "http"
               ],
               "members": [{
                  "servicePort": 80,
                  "serverAddresses": [
                     "192.0.1.10",
                     "192.0.1.11"
                  ]
               }]
            }
         }
      }
   }
}

This declaration creates a virtual server and a pool. But if you are familiar with creating objects on the BIG-IP system you know there are properties required that are not included in our declaration. As part of the validation process, BIG-IP AS3 includes defaults for required values if they are not specified in the declaration. For example, the following is the declaration after the system adds the defaults (you can see these defaults by POSTing to /mgmt/shared/appsvcs/declare?show=full or using GET with ?show=full).

{
  "results": [{
    "message": "success",
    "lineCount": 22,
    "code": 200,
    "host": "localhost",
    "tenant": "Sample_01",
    "runTime": 689
  }],
  "declaration": {
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "urn:uuid:33045210-3ab8-4636-9b2a-c98d22ab915d",
    "label": "Sample 1",
    "remark": "Simple HTTP application with RR pool",
    "Sample_01": {
      "class": "Tenant",
      "A1": {
        "class": "Application",
        "service": {
          "class": "Service_HTTP",
          "virtualAddresses": [
            "10.0.1.10"
          ],
          "pool": "web_pool",
          "virtualPort": 80,
          "persistenceMethods": [
            "cookie"
          ],
          "profileHTTP": "basic",
          "layer4": "tcp",
          "profileTCP": "normal",
          "enable": true,
          "maxConnections": 0,
          "snat": "auto",
          "addressStatus": true,
          "mirroring": "none",
          "lastHop": "default",
          "translateClientPort": false,
          "translateServerAddress": true,
          "translateServerPort": true
        },
        "web_pool": {
          "class": "Pool",
          "monitors": [
            "http"
          ],
          "members": [{
            "servicePort": 80,
            "serverAddresses": [
              "192.0.1.10",
              "192.0.1.11"
            ],
            "enable": true,
            "connectionLimit": 0,
            "rateLimit": -1,
            "dynamicRatio": 1,
            "ratio": 1,
            "priorityGroup": 0,
            "adminState": "enable",
            "addressDiscovery": "static"
          }],
          "loadBalancingMode": "round-robin",
          "minimumMembersActive": 1,
          "reselectTries": 0,
          "serviceDownAction": "none",
          "slowRampTime": 10,
          "minimumMonitors": 1
        },
        "enable": true
      },
      "enable": true,
      "defaultRouteDomain": 0
    },
    "updateMode": "selective",
    "controls": {
      "archiveTimestamp": "2018-07-03T17:36:42.795Z",
      "class": "Controls",
      "logLevel": "error",
      "trace": false
    }
  }
}

Back to top

Example 2: HTTPS application

In this example, the declaration results in the configuration for an HTTPS application. It creates the following objects on the BIG-IP:

  • Partition (tenant) named Sample_02.
  • Virtual server (HTTPS) named service.
  • TLS/SSL profile (including certificate and private key) named TLS_Server. In the BIG-IP UI, this is a Client SSL profile.
  • Pool named web_pool using the predictive (node) load balancing method, with 2 members monitored by the default HTTP health monitor.
{
  "class": "AS3",
  "action": "deploy",
  "persist": true,
  "declaration": {
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "123abc",
    "label": "Sample 2",
    "remark": "HTTPS with predictive-node pool",
    "Sample_02": {
      "class": "Tenant",
      "A1": {
        "class": "Application",
        "service": {
          "class": "Service_HTTPS",
          "virtualAddresses": [
            "192.0.2.11"
          ],
          "pool": "web_pool",
          "serverTLS": "webtls"
        },
        "web_pool": {
          "class": "Pool",
          "loadBalancingMode": "predictive-node",
          "monitors": [
            "http"
          ],
          "members": [{
            "servicePort": 80,
            "serverAddresses": [
              "192.0.2.12",
              "192.0.2.13"
            ]
          }]
        },
        "webtls": {
          "class": "TLS_Server",
          "certificates": [{
            "certificate": "webcert"
          }]
        },
        "webcert": {
          "class": "Certificate",
          "remark": "in practice we recommend using a passphrase",
          "certificate": "-----BEGIN CERTIFICATE-----\nMIICnDCCAgWgAwIBAgIJAJ5n2b0OCEjwMA0GCSqGSIb3DQEBCwUAMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdTZWF0dGxlMRQwEgYDVQQKDAtmNV9OZXR3b3JrczEbMBkGA1UEAwwSc2FtcGxlLmV4YW1wbGUubmV0MB4XDTE3MTEyNjE5NTAyNFoXDTE4MDIyNTE5NTAyNFowZzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxFDASBgNVBAoMC2Y1X05ldHdvcmtzMRswGQYDVQQDDBJzYW1wbGUuZXhhbXBsZS5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALEsuXmSXVQpYjrZPW+WiTBjn491mwZYT7Q92V1HlSBtM6WdWlK1aZN5sovfKtOX7Yrm8xa+e4o/zJ2QYLyyv5O+t2EGN/4qUEjEAPY9mwJdfzRQy6Hyzm84J0QkTuUJ/EjNuPji3D0QJRALUTzu1UqqDCEtiN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l28Ynh9lmGMdv+5QYMZvKG0LOg/n3m8uJ6sKy\nIzzvaJswwn0j5P5+czyoV5CvvdCfKnNb+3jUEN8I0PPwjBGKr4B1ojwhogTM248V\nHR69D6TxFVMfGpyJhCPkbGEGbpEpcffpgKuC/mEtMqyDQXJNaV5HO6HgAJ9F1P6v\n5ehHHTMRvzCCFiwndHdlMXUjqSNjww6me6dr6LiAPbejdzhL2vWx1YqebOcwQx3G\n-----END RSA PRIVATE KEY-----",
          "passphrase": {
            "ciphertext": "ZjVmNQ==",
            "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJub25lIn0"
          }
        }
      }
    }
  }
}

The following is the declaration after the system adds the defaults (the result of POSTing with ?show=full).

{
  "results": [{
    "message": "success",
    "lineCount": 26,
    "code": 200,
    "host": "localhost",
    "tenant": "Sample_02",
    "runTime": 929
  }],
  "declaration": {
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "123abc",
    "label": "Sample 2",
    "remark": "HTTPS with predictive-node pool",
    "Sample_02": {
      "class": "Tenant",
      "A1": {
        "class": "Application",
        "service": {
          "class": "Service_HTTPS",
          "virtualAddresses": [
            "192.0.2.11"
          ],
          "pool": "web_pool",
          "serverTLS": "webtls",
          "virtualPort": 443,
          "redirect80": true,
          "persistenceMethods": [
            "cookie"
          ],
          "profileHTTP": "basic",
          "layer4": "tcp",
          "profileTCP": "normal",
          "enable": true,
          "maxConnections": 0,
          "snat": "auto",
          "addressStatus": true,
          "mirroring": "none",
          "lastHop": "default",
          "translateClientPort": false,
          "translateServerAddress": true,
          "translateServerPort": true
        },
        "web_pool": {
          "class": "Pool",
          "loadBalancingMode": "predictive-node",
          "monitors": [
            "http"
          ],
          "members": [{
            "servicePort": 80,
            "serverAddresses": [
              "192.0.2.12",
              "192.0.2.13"
            ],
            "enable": true,
            "connectionLimit": 0,
            "rateLimit": -1,
            "dynamicRatio": 1,
            "ratio": 1,
            "priorityGroup": 0,
            "adminState": "enable",
            "addressDiscovery": "static"
          }],
          "minimumMembersActive": 1,
          "reselectTries": 0,
          "serviceDownAction": "none",
          "slowRampTime": 10,
          "minimumMonitors": 1
        },
        "webtls": {
          "class": "TLS_Server",
          "certificates": [{
            "certificate": "webcert"
          }],
          "requireSNI": false,
          "ciphers": "DEFAULT",
          "authenticationMode": "ignore",
          "authenticationFrequency": "one-time"
        },
        "webcert": {
          "class": "Certificate",
          "remark": "in practice we recommend using a passphrase",
          "certificate": "-----BEGIN CERTIFICATE-----\nMIICnDCCAgWgAwIBAgIJAJ5n2b0OCEjwMA0GCSqGSIb3DQEBCwUAMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdTZWF0dGxlMRQwEgYDVQQKDAtmNV9OZXR3b3JrczEbMBkGA1UEAwwSc2FtcGxlLmV4YW1wbGUubmV0MB4XDTE3MTEyNjE5NTAyNFoXDTE4MDIyNTE5NTAyNFowZzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxFDASBgNVBAoMC2Y1X05ldHdvcmtzMRswGQYDVQQDDBJzYW1wbGUuZXhhbXBsZS5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALEsuXmSXVQpYjrZPW+WiTBjn491mwZYT7Q92V1HlSBtM6WdWlK1aZN5sovfKtOX7Yrm8xa+e4o/zJ2QYLyyv5O+t2EGN/4qUEjEAPY9mwJdfzRQy6Hyzm84J0QkTuUJ/EjNuPji3D0QJRALUTzu1UqqDCEtiN9OGyXEkh7uvb7BAgMBAAGjUDBOMB0GA1UdDgQWBBSVHPNrGWrjWyZvckQxFYWO59FRFjAfBgNVHSMEGDAWgBSVHPNrGWrjWyZvckQxFYWO59FRFjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4GBAJeJ9SEckEwPhkXOm+IuqfbUS/RcziifBCTmVyE+Fa/j9pKSYTgiEBNdbJeBEa+gPMlQtbV7Y2dy8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n-----END RSA PRIVATE KEY-----",
          "passphrase": {
            "ciphertext": "JE0kaEMkTHlpaDBaRVVqNkRtNm16YXh5RktyZz09",
            "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJmNXN2In0=",
            "miniJWE": true,
            "allowReuse": false,
            "ignoreChanges": false
          }
        },
        "enable": true
      },
      "enable": true,
      "defaultRouteDomain": 0
    },
    "updateMode": "selective",
    "controls": {
      "archiveTimestamp": "2018-07-03T17:51:47.813Z",
      "class": "Controls",
      "logLevel": "error",
      "trace": false
    }
  }
}

Back to top

Example 3: TCP virtual server to ICAP with custom monitor

In this example, we show a declaration that creates a TCP virtual server. This virtual server contains a custom health monitor for ICAP.

This example creates the following objects on the BIG-IP:

  • Partition (tenant) named Sample_03.
  • A TCP virtual server named service on port 1344.
  • A TCP profile using the mptcp-mobile-optimized parent.
  • A pool named svc_pool containing two members (also using port 1344).
  • A custom TCP health monitor with custom Send and Receive strings for ICAP.
{
  "class": "AS3",
  "action": "deploy",
  "persist": true,
  "declaration": {
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "789ghi",
    "label": "Sample 3",
    "remark": "TCP load-balanced to ICAP with custom monitor",
    "Sample_03": {
      "class": "Tenant",
      "A1": {
        "class": "Application",
        "service": {
          "class": "Service_TCP",
          "virtualAddresses": [
            "10.0.5.10"
          ],
          "virtualPort": 1344,
          "pool": "svc_pool"
        },
        "svc_pool": {
          "class": "Pool",
          "monitors": [{
            "use": "icap_monitor"
          }],
          "members": [{
            "servicePort": 1344,
            "serverAddresses": [
              "192.0.5.10",
              "192.0.5.11"
            ]
          }]
        },
        "icap_monitor": {
          "class": "Monitor",
          "monitorType": "tcp",
          "send": "OPTIONS icap://icap.example.net/ ICAP/1.0\r\nUser-Agent: f5-ADC\r\n\r\n",
          "receive": "ICAP/1.0 200 OK",
          "adaptive": false
        }
      }
    }
  }
}

The following is the declaration after the system adds the defaults.

{
  "results": [{
    "message": "success",
    "lineCount": 23,
    "code": 200,
    "host": "localhost",
    "tenant": "Sample_03",
    "runTime": 677
  }],
  "declaration": {
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "789ghi",
    "label": "Sample 3",
    "remark": "TCP load-balanced to ICAP with custom monitor",
    "Sample_03": {
      "class": "Tenant",
      "A1": {
        "class": "Application",
        "service": {
          "class": "Service_TCP",
          "virtualAddresses": [
            "10.0.5.10"
          ],
          "virtualPort": 1344,
          "pool": "svc_pool",
          "persistenceMethods": [
            "source-address"
          ],
          "layer4": "tcp",
          "profileTCP": "normal",
          "enable": true,
          "maxConnections": 0,
          "snat": "auto",
          "addressStatus": true,
          "mirroring": "none",
          "lastHop": "default",
          "translateClientPort": false,
          "translateServerAddress": true,
          "translateServerPort": true
        },
        "svc_pool": {
          "class": "Pool",
          "monitors": [{
            "use": "icap_monitor"
          }],
          "members": [{
            "servicePort": 1344,
            "serverAddresses": [
              "192.0.5.10",
              "192.0.5.11"
            ],
            "enable": true,
            "connectionLimit": 0,
            "rateLimit": -1,
            "dynamicRatio": 1,
            "ratio": 1,
            "priorityGroup": 0,
            "adminState": "enable",
            "addressDiscovery": "static"
          }],
          "loadBalancingMode": "round-robin",
          "minimumMembersActive": 1,
          "reselectTries": 0,
          "serviceDownAction": "none",
          "slowRampTime": 10,
          "minimumMonitors": 1
        },
        "icap_monitor": {
          "class": "Monitor",
          "monitorType": "tcp",
          "send": "OPTIONS icap://icap.example.net/ ICAP/1.0\r\nUser-Agent: f5-ADC\r\n\r\n",
          "receive": "ICAP/1.0 200 OK",
          "adaptive": false,
          "targetAddress": "",
          "interval": 5,
          "upInterval": 0,
          "timeUntilUp": 0,
          "timeout": 16,
          "targetPort": 0,
          "dscp": 0,
          "receiveDown": "",
          "reverse": false,
          "transparent": false,
          "adaptiveDivergenceType": "relative",
          "adaptiveDivergenceMilliseconds": 500,
          "adaptiveDivergencePercentage": 100,
          "adaptiveLimitMilliseconds": 1000,
          "adaptiveWindow": 180
        },
        "enable": true
      },
      "enable": true,
      "defaultRouteDomain": 0
    },
    "updateMode": "selective",
    "controls": {
      "archiveTimestamp": "2018-07-03T18:24:59.623Z",
      "class": "Controls",
      "logLevel": "error",
      "trace": false
    }
  }
}

Back to top

Example 4: Calling resources from a URL source

In this example, we show how BIG-IP AS3 can fetch an external resource value from a URL using HTTP or HTTPS. This is useful if you have a bulky configuration resource (such as an F5 WAF security policy (see WAF Policy) or an iRule); you can store the resource on a webserver under your control, then include a URL reference to it in the declaration. In this example, our declaration includes an “under maintenance” iRule from a URL source. In this example, we also set the historyLimit, which sets the number of previously-deployed declarations BIG-IP AS3 saves for review using GET (for example using ?age=list) and for use with POST action redeploy and redeployAge=N.

Tip

BIG-IP AS3 3.28 adds the ability to retrieve data from a URL that is using bearer token authentication (see Bearer Token Auth).

This example creates the following objects on the BIG-IP:

  • Partition (tenant) named Sample_04.
  • A HTTP virtual server named service, which includes the iRule pulled from an external location.
  • A TCP profile using the mptcp-mobile-optimized parent.
  • A pool named web_pool containing two members.
{
  "class": "AS3",
  "action": "deploy",
  "persist": true,
  "historyLimit": 10,
  "declaration": {
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "8316914",
    "label": "Sample 4",
    "remark": "Simple HTTP application referencing an externally hosted iRule",
    "Sample_04": {
      "class": "Tenant",
      "ApplicationA": {
        "class": "Application",
        "service": {
          "class": "Service_HTTP",
          "iRules": ["Maintenance_iRule"],
          "virtualAddresses": [
            "10.0.1.170"
          ],
          "pool": "web_pool"
        },
        "web_pool": {
          "class": "Pool",
          "monitors": [
            "http"
          ],
          "members": [{
            "servicePort": 80,
            "serverAddresses": [
              "192.0.1.170",
              "192.0.1.171"
            ]
          }]
        },
        "Maintenance_iRule": {
          "class": "iRule",
          "iRule": {
            "url": "https://raw.githubusercontent.com/f5devcentral/f5-automation-labs/master/files/irules/maintenance-page.irule"
          }
        }
      }
    }
  }
}

The following is the declaration after the system adds the defaults. In this example, we use the GET method with ?show=expanded, to show the contents of the iRule that BIG-IP AS3 retrieved.

{
  "class": "ADC",
  "schemaVersion": "3.0.0",
  "id": "8316914",
  "label": "Sample 4",
  "remark": "Simple HTTP application referencing an externally hosted iRule",
  "Sample_04": {
    "class": "Tenant",
    "ApplicationA": {
      "class": "Application",
      "service": {
        "class": "Service_HTTP",
        "iRules": [
          "/Sample_04/ApplicationA/Maintenance_iRule"
        ],
        "virtualAddresses": [
          "10.0.1.172"
        ],
        "pool": "/Sample_04/ApplicationA/web_pool",
        "virtualPort": 80,
        "persistenceMethods": [
          "cookie"
        ],
        "profileHTTP": "basic",
        "layer4": "tcp",
        "enable": true,
        "maxConnections": 0,
        "snat": "auto",
        "addressStatus": true,
        "mirroring": "none",
        "lastHop": "default",
        "translateClientPort": false,
        "translateServerAddress": true,
        "translateServerPort": true
      },
      "web_pool": {
        "class": "Pool",
        "monitors": [
          "http"
        ],
        "members": [{
          "servicePort": 80,
          "serverAddresses": [
            "192.0.1.170",
            "192.0.1.171"
          ],
          "enable": true,
          "connectionLimit": 0,
          "rateLimit": -1,
          "dynamicRatio": 1,
          "ratio": 1,
          "priorityGroup": 0,
          "adminState": "enable",
          "addressDiscovery": "static"
        }],
        "loadBalancingMode": "round-robin",
        "minimumMembersActive": 1,
        "reselectTries": 0,
        "serviceDownAction": "none",
        "slowRampTime": 10,
        "minimumMonitors": 1
      },
      "Maintenance_iRule": {
        "class": "iRule",
        "iRule": "when HTTP_REQUEST {\n   HTTP::respond 200 content {\n      <html>\n         <head>\n            <title>Blocked Page</title>\n         </head>\n         <body>\n            We are sorry, but the site you are looking for is currently under Maintenance<br>\n            If you feel you have reached this page in error, please try again. Thanks for coming\n         </body>\n      </html>\n   } noserver Cache-Control no-cache Connection Close\n}\n",
        "expand": true
      },
      "enable": true
    },
    "enable": true,
    "defaultRouteDomain": 0
  },
  "controls": {
    "archiveTimestamp": "2018-05-02T20:12:06.639Z",
    "class": "Controls",
    "logLevel": "error",
    "trace": false
  },
  "updateMode": "selective"
}


Example 4a: Using PATCH to add a new server to the pool

Now we use the PATCH method to add a new server address to the load balancing pool we created using the previous declaration, without having to resend the entire declaration. For more information on PATCH, see HTTP Methods.

In this example, we are adding a single IP address to the web_pool we sent in the previous declaration. When using PATCH, using the proper path is extremely important, and you must specify the location in an array where necessary. In the following, we use a dash at the end of the path, which means the system adds the new server to the end of the array (you can also use a number beginning with 0 to specify a specific location in the array). Members is also an array, so even though there is only one object in our array, we must use /0/ to specify this first object.

If necessary, review the declaration in Example 4 (or first use GET https://<BIG-IP>/mgmt/shared/appsvcs/declare/TenantA).

Then use PATCH https://<BIG-IP>/mgmt/shared/appsvcs/declare with the following body:

[
  {
    "op": "add",
    "path": "/Sample_04/ApplicationA/web_pool/members/0/serverAddresses/-",
    "value": "192.0.1.172"
  }
]

After submitting this PATCH, the system returns the following (new server address highlighted):

{
  "results": [{
    "message": "success",
    "lineCount": 17,
    "code": 200,
    "host": "localhost",
    "tenant": "Sample_04",
    "runTime": 987
  }],
  "declaration": {
    "Sample_04": {
      "class": "Tenant",
      "ApplicationA": {
        "class": "Application",
        "service": {
          "class": "Service_HTTP",
          "iRules": [
            "Maintenance_iRule"
          ],
          "virtualAddresses": [
            "10.0.1.170"
          ],
          "pool": "web_pool"
        },
        "web_pool": {
          "class": "Pool",
          "monitors": [
            "http"
          ],
          "members": [{
            "servicePort": 80,
            "serverAddresses": [
              "192.0.1.170",
              "192.0.1.171",
              "192.0.1.172"
            ]
          }]
        },
        "Maintenance_iRule": {
          "class": "iRule",
          "iRule": {
            "url": "https://raw.githubusercontent.com/f5devcentral/f5-automation-labs/master/files/irules/maintenance-page.irule"
          }
        }
      }
    },
    "class": "ADC",
    "schemaVersion": "3.0.0",
    "id": "8316914",
    "label": "Sample 4",
    "remark": "Simple HTTP application referencing an externally hosted iRule",
    "controls": {
      "archiveTimestamp": "2018-06-01T16:52:07.173Z"
    }
  }
}

Again, see Additional Declarations for more example declarations.

Back to top