How to automate integration testing for Azure Resource Protected by Private End Points?

Siegfried Heintze 1,881 Reputation points
2024-07-16T19:51:54.2766667+00:00

My bicep file deploys and creates a service bus queue (protected by a firewall) and a function app (and associated storage account) protected by private end points. The Function app reads the queue and creates log statements.

For manual testing, we deploy a custom web app (also inside the VNet and protected with a private end point) with a simple GUI that writes test data to the service bus queue.

To perform the manual test, we access a VM (also inside the VNET and protected by private end point) via Bastion and repeatedly click the "Send Test Data" button on the Web App and watch the function app logs with "az webapp log tail". If we see the test data in the logs (using regular expressions) the test passes.

I was reviewing this solution: https://www.c-sharpcorner.com/article/creating-unit-tests-for-azure-functions/ I think it uses a database. We don't have a database in our implementation.

(1) How might we automate this test?

(2) Could we trigger the run of such an automated test when we "git push" to master? Could a failure of the test cause a git "pull request" to be rejected automatically?

(3) Are there any testing frameworks out there that could help us out?

Thanks

Siegfried

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,973 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pinaki Ghatak 4,285 Reputation points Microsoft Employee
    2024-07-17T10:06:17.95+00:00

    Hello @Siegfried Heintze

    To automate integration testing for Azure Resource Protected by Private End Points, you can use Azure DevOps pipelines. You can create a pipeline that deploys your Bicep file and runs automated tests against the deployed resources. Here are the steps you can follow to create an automated test pipeline:

    1. Create an Azure DevOps project and repository.
    2. Create a pipeline that deploys your Bicep file to your Azure subscription.
    3. Add a task to the pipeline that runs your automated tests against the deployed resources. You can use tools like Selenium or Appium to automate the testing of your web app.
    4. Configure the pipeline to trigger on a git push to master.
    5. If the tests fail, you can configure the pipeline to fail the build and prevent a pull request from being merged.
    6. There are several testing frameworks available for Azure Functions, including the one you mentioned in your question. You can also use tools like Postman or Newman to test your API endpoints.

    I hope this helps


1 additional answer

Sort by: Most helpful
  1. Ryan Hill 28,106 Reputation points Microsoft Employee
    2024-07-25T22:03:58.2666667+00:00

    Hi @Siegfried Heintze

    I took a look at the link you shared. If you're wanting to do integration in your pipeline, I think you can leverage a continuous webjob for this. I came across https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-nodejs-how-to-use-queues?tabs=passwordless and you can leverage this JavaScript code with tweaks to fit your environment.

    While this doc is for deploying the webjob using VS, the main thing is that the code is deployed to appropriate folder. But this Stackoverflow post illustrates using a pipeline flow. Just remember that your app service needs to be set to Always On.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.