Preview deployment
Simulate a request against a function in Azion Console and read the response the code returns before the function serves traffic.
Preview deployment runs a function in Azion Console and shows the response the code returns. It calls PreviewProvider, an auxiliary function in the source code that builds a simulated request and passes it to the handler. The output appears in the code editor, so you read the response before the function serves traffic.
PreviewProvider function
PreviewProvider is the entry point of a preview. It builds the request the preview sends, calls the function that processes that request, and returns the response the preview renders:
The handler reads the properties of that request, so the values set inside PreviewProvider decide which path through the function runs.
Request simulation
Change the values inside PreviewProvider to exercise a different path through the function. A handler that branches on the request method returns HTML for a GET and JSON for a POST:
Each branch sets the content-type header for the format it returns. Switch the method inside PreviewProvider from GET to POST to read the other response.
Response rendering
The preview renders a response by its content-type header:
content-type | Preview output |
|---|---|
text/html | The HTML page, rendered. |
application/json | The JSON body the function returns. |
Azion Console shows the output in the code editor of the function. Select Open to show the same output in a separate browser tab. The inspect tool inside Preview deployment shows the behavior of the function in real time.