F5 AS3 REST API is used to automate application deployment.
In this method, we only send the final desired configuration via REST API in JSON format and F5 prepares the application based on the configuration. This method is called declarative automation.
F5 AS3 REST API
To start automating application deployment via F5 AS3 REST API, we first need to install F5 AS3 extension.
In our example, the F5 AS3 extension is already installed. In the previous section, we discussed and learned how to install the F5 AS3 extension.
prepare JSON configuration file
to use AS3 to automate application deployment, we need final configuration in the format of JSON.
There are many methods you can use to convert tmsh configuration to AS3 compatible configuration like ACC or VS Code F5 Extension.
But this is out of scope of this course and we assume that we have already prepared AS3 JSON configuration file.
Here are some AS3 configuration examples you can use to test for your test/lab environment.
deploy a new application using AS3
I will use the configuration example in this link with a few changes to prepare a simple HTTP application like the ones we prepared during the course.
This example prepares a new virtual server with a virtual IP address and a web pool with three pool members in a new container.
{ "class": "AS3", "action": "deploy", "persist": true, "declaration": { "class": "ADC", "schemaVersion": "3.0.0", "id": "urn:uuid:33045210-3ab8-4636-9b2a-c98d22ab915d", "label": "Tenant1", "remark": "Simple HTTP Service with Round-Robin Load Balancing", "Tenant1": { "class": "Tenant", "A1": { "class": "Application", "http_service": { "class": "Service_HTTP", "virtualAddresses": [ "192.168.2.105" ], "pool": "web_pool" }, "web_pool": { "class": "Pool", "monitors": [ "http" ], "members": [ { "servicePort": 80, "serverAddresses": [ "192.168.10.111", "192.168.10.112", "192.168.10.113" ] } ] } } } } }
Then we have to use a tool such as “curl” or “postman” to send AS3 JSON configuration file through REST API. I will use postman for this example.
In postman, I use “POST” HTTP method to send the configuration.
The URL to send the configuration is always “https://F5-IP-ADDRESS/mgmt/shared/appsvcs/declare”. In my case it is “https://192.168.1.181/mgmt/shared/appsvcs/declare”.
In the “Authorization” tab, we use “Basic Authentication” as the authentication type and enter the username and password to connect to the F5 device.
In the “Body” tab, we send prepared JSON configuration file. We select “raw” and “JSON” as input type and copy the configuration to the body section.
Then we click on the “Send” button to send the configuration to deploy the new application.
check the new application deployed by F5 AS3
If we check the result in F5 BIG-IP, we see that a new partition named “Tenant1” is created.
We also check the virtual server and pool to ensure that they are created as we defined in the JSON configuration file.