Lab 2.2: Modify Tenant/Application using AS3

Note

Estimated time to complete: 25 minutes

Using the declarative AS3 API, let’s modify the HTTP application created during the previous Lab 1 - Task 1 through BIG-IQ using an updated AS3 declaration.

In this lab, we will show 2 use cases.

  • Task 5a will show an example of updating a tenant/application by re-posting the entire declaration using POST. In this case, user A and user B need to know the full content of the Tenant.
  • Task 5b will show an example of updating a tenant/application by posting only what’s new to an existing declaration using PATCH. In this case, user A and user B don’t need to know the full content of the Tenant but 1 single tenant can be shared.

Lab environment access

If you have not yet visited the page Getting Started, please do so.

Task 5a - Add a HTTPS Application to existing HTTP AS3 Declaration (using POST)

This declaration will add a HTTPS application to a existing HTTP application. In this task, we will re-submit the entire declaration.

  1. Start with the previous AS3 Declaration from lab 1 - Task 1
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
    "$schema": "https://raw.githubusercontent.com/F5Networks/f5-appsvcs-extension/master/schema/latest/as3-schema.json",
    "class": "AS3",
    "action": "deploy",
    "persist": true,
    "declaration": {
        "class": "ADC",
        "schemaVersion": "3.7.0",
        "id": "example-declaration-01",
        "label": "Task1",
        "remark": "Task 1 - HTTP Application Service",
        "target": {
            "address": "10.1.1.8"
        },
        "Task1": {
            "class": "Tenant",
            "MyWebApp1http": {
                "class": "Application",
                "template": "http",
                "statsProfile": {
                    "class": "Analytics_Profile",
                     "collectedStatsInternalLogging": true,
                     "collectPageLoadTime": true,
                     "collectClientSideStatistics": true,
                     "collectResponseCode": true
                },
                "serviceMain": {
                    "class": "Service_HTTP",
                    "virtualAddresses": [
                        "10.1.10.110"
                    ],
                    "pool": "web_pool",
                    "profileAnalytics": {
                        "use": "statsProfile"
                    }
                },
                "web_pool": {
                    "class": "Pool",
                    "monitors": [
                        "http"
                    ],
                    "members": [
                        {
                            "servicePort": 80,
                            "serverAddresses": [
                                "10.1.20.110",
                                "10.1.20.111"
                            ],
                            "shareNodes": true
                        }
                    ]
                }
            }
        }
    }
}
  1. Add the below application service to the existing AS3 declaration in the JSON validator. The validator is your IDE (Integrated development environment).

    Use the IDE available within the lab environment, click on the Access button of the Ubuntu Lamp Server system and select Visual Studio Code.

    Note

    It is recommended to validate your AS3 declaration against the schema using Microsoft Visual Studio Code.

Note

Add a “,” at the end of the MyWebApp1 statement. If you want to “minimize” MyWebApp1 statement (like in the screenshot below), click on the tiny down arrow on the left of this line

lab-2-1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"MyWebApp6https": {
        "class": "Application",
        "template": "https",
        "statsProfile": {
            "class": "Analytics_Profile",
            "collectClientSideStatistics": true,
            "collectOsAndBrowser": false,
            "collectMethod": false
        },
        "serviceMain": {
            "class": "Service_HTTPS",
            "virtualAddresses": [
                "10.1.10.129"
            ],
            "pool": "web_pool",
            "profileAnalytics": {
                "use": "statsProfile"
            },
            "serverTLS": "webtls"
        },
        "web_pool": {
            "class": "Pool",
            "monitors": [
                "http"
            ],
            "members": [
                {
                    "servicePort": 80,
                    "serverAddresses": [
                        "10.1.20.128",
                        "10.1.20.129"
                    ],
                    "shareNodes": true
                }
            ]
        },
        "webtls": {
            "class": "TLS_Server",
            "certificates": [
                {
                    "certificate": "webcert"
                }
            ]
        },
        "webcert": {
            "class": "Certificate",
            "certificate": {
                "bigip": "/Common/default.crt"
            },
            "privateKey": {
                "bigip": "/Common/default.key"
            }
        }
    }
  1. In Visual Studio Code, use the Visual Studio code REST client extension and authenticate to BIG-IQ (follow instructions).

  2. Use the BIG-IQ AS3 Declaration call in order to create the service on the BIG-IP through BIG-IQ. The method and URL used will be POST https://10.1.1.4/mgmt/shared/appsvcs/declare?async=true. Copy/Paste the AS3 declaration to the body under the call using the REST client VS code extension.

    This will give you an ID which you can query using the BIG-IQ Check AS3 Deployment Task.

  3. Use the BIG-IQ Check AS3 Deployment Task call to ensure that the AS3 deployment is successful without errors:

    GET https://10.1.1.4/mgmt/shared/appsvcs/task/<id>

  4. Login on BIG-IQ as david, go to Applications tab and check the application is displayed and analytics are showing.

Warning

Starting 7.0, BIG-IQ displays AS3 application services created using the AS3 Declare API as Unknown Applications. You can move those application services using the GUI, the Move/Merge API, bigiq_move_app_dashboard F5 Ansible Galaxy role or create it directly into Application in BIG-IQ using the Deploy API to define the BIG-IQ Application name.

Task 5b - Add a HTTPS Application to existing HTTP AS3 Declaration (using PATCH)

Warning

This isn’t the recommended way of adding an application to an existing Tenant. The method described in Task 5a is preferred. The PATCH operation will be fully supported starting with BIG-IQ 7.0/AS3.12 and above (not supported in BIG-IQ 6.1/AS3.7)

This declaration will create add a HTTP application to a existing Tenant. In this task, we will submit only the new application using the PATCH.

Note

The target from the previous declaration is preserved when building the new declaration with the patch.

  1. Add the below application service to the existing AS3 declaration in the validator. The validator is your IDE (Integrated development environment).

    Use the IDE available within the lab environment, click on the Access button of the Ubuntu Lamp Server system and select Visual Studio Code.

    You can also use an online tool such as www.jsonschemavalidator.net.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 {
     "$schema": "https://raw.githubusercontent.com/F5Networks/f5-appsvcs-extension/master/schema/latest/as3-schema.json",
     "class": "AS3",
     "action": "patch",
     "patchBody": [
         {
            "target": {
                 "address": "10.1.1.8"
             },
             "path": "/Task1/MyWebApp7http",
             "op": "add",
             "value": {
                 "class": "Application",
                 "template": "http",
                 "serviceMain": {
                     "class": "Service_HTTP",
                     "virtualAddresses": [
                         "10.1.10.131"
                     ],
                     "pool": "web_pool"
                 },
                 "web_pool": {
                     "class": "Pool",
                     "monitors": [
                         "http"
                     ],
                     "members": [
                         {
                             "servicePort": 80,
                             "serverAddresses": [
                               "10.1.20.130",
                               "10.1.20.131"
                             ],
                             "shareNodes": true
                         }
                     ]
                 }
             }
         }
     ]
 }
  1. In Visual Studio Code, use the Visual Studio code REST client extension and authenticate to BIG-IQ (follow instructions).

  2. Use the BIG-IQ AS3 Declaration call in order to create the service on the BIG-IP through BIG-IQ. The method and URL used will be POST https://10.1.1.4/mgmt/shared/appsvcs/declare?async=true. Copy/Paste the AS3 declaration to the body under the call using the REST client VS code extension.

    This will give you an ID which you can query using the BIG-IQ Check AS3 Deployment Task.

  3. Use the BIG-IQ Check AS3 Deployment Task call to ensure that the AS3 deployment is successful without errors:

    GET https://10.1.1.4/mgmt/shared/appsvcs/task/<id>

  4. Login on BIG-IQ as david, go to Applications tab and check the application is displayed and analytics are showing.

Warning

Starting 7.0, BIG-IQ displays AS3 application services created using the AS3 Declare API as Unknown Applications. You can move those application services using the GUI, the Move/Merge API, bigiq_move_app_dashboard F5 Ansible Galaxy role or create it directly into Application in BIG-IQ using the Deploy API to define the BIG-IQ Application name.