4.6 KiB
How to test the Orchestrator Function
Getting Started
To verify that the Orchestrator Function is executing correctly, we will use Postman using endpoints of the Management API to consult the state of the service, start/stop service, where the calls will place a message in the queue of the Storage Account created in the previous steps, and this will trigger the corresponding function (start-virtual-machine
and stop-virtual-machine
).
Check Service State
-
Open Postman and create a new GET request pointing to the following address:
https://{{webAppUrl}}/api/service/{{serviceId}}/state
.NOTE: Replace the placeholder
{{webAppUrl}}
with the URL of the Web App created in the previous steps.For the placeholderserviceId
, enter the id of the Service obtained in the previous steps. -
You must now obtain the token that allows validation to use the Management API endpoints. Check the following documentation, which explains how to obtain the token.
-
Once the token is obtained, in the authorization tab, select
Bearer Token
forType
and add the authorization token in the corresponding input. -
In the header tab, add (if it does not exist) a new key
Content-Type
with the valueapplication/json
. -
In the Body tab select none.
-
Then click the button Send and the request will be sent to the API, you should receive a response with the status
200
Ok and in the propertypowerState
of the json response you can see the current service status.
Start Service
-
You must create New tab, within Postman go to File > New Tab.
-
Create a new POST request pointing to the following address:
https://{{webAppUrl}}/api/service/{{serviceId}}/start
.NOTE: Replace the placeholder
{{webAppUrl}}
with the URL of the Web App created in the previous steps.For the placeholderserviceId
, enter the id of the Service obtained in the previous steps. -
Use the same authorization and content-type configurations from the Check Service State section (from steps 2 to 5).
-
Then click the button Send and the request will be sent to the API, you should receive a response with the status
200
OK. If we wait a few minutes and you go back to check Service state, you will notice that in the propertypowerState
of the json returned it will bePowerState/running
, which indicates that the Service is started.
Stop Service
-
You must create New tab, within Postman go to File > New Tab.
-
Create a new POST request pointing to the following address:
https://{{webAppUrl}}/api/service/{{serviceId}}/stop
.NOTE: Replace the placeholder
{{webAppUrl}}
with the URL of the Web App created in the previous steps.For the placeholderserviceId
, enter the id of the Service obtained in the previous steps. -
Use the same authorization and content-type configurations from the Check Service State section (from steps 2 to 5).
-
Then click the button Send and the request will be sent to the API, you should receive a response with the status
200
OK. If we wait a few minutes and you go back to check Service state, you will notice that in the propertypowerState
of the json returned it will bePowerState/deallocated
, which indicates that the Service is stopped.
Queue Creations after having started and stoped the Service
Once the endpoints have been called to start and stop the Service, within our Storage Account in the Queues section, we can verify that two queues were created (start-virtual-machine-queue
and stop-virtual-machine-queue
) corresponding to each action. They are empty since the messages were dequeued when they were triggered by the corresponding function.