App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide What is Azure Automation

What is Azure Automation

By Vivek Mannotra, Community Contributor -

Table of Contents

Microsoft is an interesting company with a storied history that spans several decades. It has managed to remain a dominant player in the technology industry till date. They certainly had their share of wins and losses over the years, but it is currently in a very strong position thanks to the success of several key products and services like Azure Cloud.

In recent years, the company has shifted its focus to cloud computing, artificial intelligence, and other emerging technologies. 

What is Azure Automation? 

Microsoft Azure is one of the company’s biggest success stories in recent years. Azure is a cloud computing platform that allows businesses to run their applications and store their data in the cloud. Azure has become a popular choice thanks to its scalability, reliability, and flexibility.

Global Market Share of Leading Cloud Infrastructure Service Providers in 2022Source

Azure Automation is a cloud-based automation service provided by Microsoft Azure. It allows users to automate the creation, deployment, monitoring, and maintenance of resources in the Azure cloud. The service provides a way to schedule, run, and track workflows, scripts, and processes across multiple platforms, including Windows and Linux environments.

With Azure Automation, users can create runbooks, which are sequences of automated tasks and processes that can be scheduled or triggered in response to specific events or conditions. These runbooks can be written in a variety of languages including PowerShell, Python, and JavaScript.

Azure Automation simplifies and streamlines the management and maintenance of resources in the Azure cloud, reducing the need for manual intervention and enabling more efficient and reliable operations.

Why is Azure Automation important? 

Microsoft has not only gained access to valuable technologies and talent, but has also been able to integrate these offerings into its broader suite of products and services. 

As a part of its product strategy, due to fierce competition with AWS and Google cloud, it is offering highly optimised cloud solutions at great prices. 

For developers who are already using tools like GitHub and Visual Studio Code, this integration can provide a seamless and efficient development experience, with easy access to powerful cloud services like Azure and automation services like Azure Automation Services.

As a result of this strategic movement, Microsoft has ensured a safe place in the highly competitive cloud and coding market as reflected from their revenue growthRevenue of Microsoft Azure Cloud Infrastructure in Q4 2022Azure Resource Manager provides a declarative language called Azure Resource Manager templates that allow developers and operators to define and manage infrastructure as code. As you mentioned, Resource Manager templates are JSON files that describe the desired state of Azure resources, including virtual machines, storage accounts, network interfaces, and more.

By using a declarative syntax, Resource Manager templates provide a consistent and repeatable way to deploy and manage Azure resources. You can define dependencies between resources, specify configuration values for each resource, and use functions to generate complex expressions or values.

Resource Manager templates can be created and edited using a variety of tools, including the Azure Portal, Visual Studio, Visual Studio Code, and various third-party editors. They can also be stored in version control systems like Git or Azure DevOps, allowing for collaboration and versioning.

Rise in Popularity of Azure DevOpsAzure popularity over the last 2 decades

Azure can be integrated with BrowserStack real device cloud to ensure that your testing infrastructure has access to all the latest devices and browsers on the cloud.

Azure Automation can help you achieve improvements like:

  • Streamline operations: Azure Automation can help streamline IT operations by automating routine tasks, such as provisioning resources, patching systems, and monitoring applications. This frees up IT staff to focus on more strategic initiatives and improves overall operational efficiency.
  • Ensure consistency: By using Azure Automation, organizations can ensure that IT processes are performed consistently and according to best practices. This helps to reduce errors and improve the quality of IT services.
  • Improve agility: Azure Automation enables organizations to quickly adapt to changing business needs by automating the deployment and configuration of resources. This helps organizations to be more agile and responsive to market changes.
  • Enhance security: By automating security processes, such as patch management and access control, Azure Automation can help organizations reduce their risk exposure and improve overall security posture.
  • Increase scalability: Azure Automation can help organizations scale their IT operations by automating the provisioning and configuration of resources. This enables organizations to quickly add or remove resources as needed, without having to manually configure each resource.

When to use Azure Automation?

The platform supports a variety of programming languages, including .NET, ASP.NET, Node.js, Python, and C/C++. The type of product teams that should be using Microsoft Azure for automation technology depends on their specific needs and requirements.

Here are some use cases for Microsoft Azure:

  1. Application Development and Deployment: Teams developing applications using .NET, ASP.NET Core, Node.js, Python, and C/C++ can use Azure to deploy their applications in the cloud. Azure offers a range of services, including virtual machines, container services, and serverless computing options, to help teams build and deploy their applications quickly and efficiently.
  2. Data Analytics and Big Data Processing: Teams working with large datasets can use Azure to process and analyze data. Azure offers services like Azure HDInsight, Azure Data Factory, and Azure Databricks to help teams manage and process big data.
  3. Internet of Things (IoT): Teams building IoT solutions can use Azure to collect, analyze, and store data from connected devices. Azure offers services like Azure IoT Hub and Azure Stream Analytics to help teams build and manage their IoT solutions.
  4. DevOps: Teams looking to automate their software development processes can use Azure DevOps to manage their entire software development lifecycle. Azure DevOps offers a range of tools and services, including source control, continuous integration, and project management tools.

Azure Automation can be used in a variety of scenarios where automation is needed to manage Azure resources and other IT processes. Here are some common use cases for Azure Automation:

  • Provisioning and Configuration Management: Azure Automation can be used to automate the provisioning and configuration of virtual machines, databases, and other resources in Azure. This can include tasks such as installing software, configuring network settings, and setting up security policies.
  • Patch Management: Azure Automation can be used to automate the patching and updating of operating systems, applications, and other software running on Azure resources. This helps to ensure that resources are always up-to-date and secure.
  • Backup and Disaster Recovery: Azure Automation can be used to automate the backup and recovery of data and applications in Azure. This can include tasks such as scheduling backups, replicating data to other regions, and restoring data in the event of a disaster.
  • Monitoring and Alerting: Azure Automation can be used to automate the monitoring and alerting of Azure resources. This can include tasks such as collecting performance metrics, analyzing logs, and sending notifications when issues are detected.
  • DevOps Automation: Azure Automation can be used to automate various tasks in a DevOps pipeline, such as building and deploying applications, testing code, and managing infrastructure as code.
  • Routine tasks: Azure Automation can be used to automate routine tasks, such as patching systems, provisioning resources, and monitoring applications. This frees up IT staff to focus on more strategic initiatives and improves overall operational efficiency.
  • Hybrid environments: For organizations that operate in hybrid environments, Azure Automation can be used to manage on-premises resources, as well as resources in the cloud. This can help organizations to achieve a consistent approach to IT management across their entire infrastructure.
  • Automated Product Management: For organizations that adopt DevOps practices, Azure Automation can be used to automate the deployment and configuration of resources, as well as the execution of tests and other tasks.
  • Compliance: For organizations that need to comply with regulatory requirements, Azure Automation can be used to automate compliance checks and audits.
  • Cost optimization: For organizations that want to optimize their cloud spending, Azure Automation can be used to automate the start and stop of resources, as well as the resizing of resources based on demand. 

Setting up Azure Pipeline for Automation Testing

Setting up an Azure Pipeline for automation testing involves a number of steps. As mentioned in the previous section you can use a number of programming languages to build and manage deployment for your apps. 

Let’s say for example we want to deploy a Python Based web application. Here’s a general outline of the process:

Step 1: Create app repository and local deployment: If you have a Python web app, make sure it’s committed to a GitHub repository. You can fork and clone this repository for an sample app to work with. 

Then, run appropriate commands for your operating system to install dependencies and run the app locally. 

Open a browser and go to http://localhost:5000 to view the app, and stop the Flask server with Ctrl+C when you’re finished.

Step 2: Define the pipeline requirements: The first step is to define the requirements for the pipeline. This includes specifying the type of platform, the target environment, and connecting CI/CD.

Once the requirements have been defined, the pipeline can be created using Azure DevOps. This involves creating a new pipeline and selecting the appropriate template.

To provision an Azure App Service instance and deploy your Python web app, follow these steps:

Sign in to the Azure portal

Open the Azure CLI by selecting the Cloud Shell button on the portal’s toolbar.

In the Cloud Shell, clone your repository using git clone. For the example app, use: 

git clone https://github.com/<your-alias>/python-sample-vscode-flask-tutorial

Change directories into the repository folder that has your Python app, so the ‘az webapp up’ command will recognize the app as Python.

Use the following command to create an App Service and initially deploy your app: 

az webapp up -n <your-appservice>

Change <your-appservice> to a name for your app service that’s unique across Azure. Typically, you use a personal or company name along with an app identifier, such as 

<your-name>-flaskpipelines

The app URL becomes :

<your-appservice>.azurewebsites.net.

From the first line of output from the previous az webapp up command, copy the name of your resource group, which is similar to :

<your-name>rg_Linux<your-region>

Enter the following command, using your resource group name, your app service name (<your-appservice>), and your startup file or command (startup.txt): 

az webapp config set -g <your-resource-group> -n <your-appservice> --startup-file <your-startup-file-or-command>

To see the running app, open a browser and go to:

http://<your-appservice>.azurewebsites.net

If you see a generic page, wait a few seconds for the App Service to start, and refresh the page. Verify that you see the title Visual Studio Flask Tutorial.

Step 3: Configure the pipeline: The pipeline must be configured to run the automated tests. This involves specifying the test scripts, the target environment, and any other required parameters. In addition, the pipeline can be configured to trigger the tests automatically when code changes are made.

Use the same email address for Azure DevOps and Azure to simplify the service connection process.

Once signed in, select the desired organization from the list or create a new one.

Create a new project or select an existing one.Create New Azure DevOps Project

Navigate to Project settings > Pipelines > Service connections and select New service connection.

Choose Azure Resource Manager from the dropdown menu and fill out the necessary information.

Configuring Azure DevOps PipelineEnsure that the option “Allow all pipelines to use this connection” is selected and then select OK.

Your new connection will appear in the Service connections list and will be ready for use in Azure Pipelines. If you want to use an Azure subscription from a different email account, refer to the instructions for creating an Azure Resource Manager service connection with an existing service principal.

Step 4: Run the pipeline: Once the pipeline is configured, it can be run to perform the automated tests. The results of the tests can be displayed in Azure DevOps, providing visibility into the test outcomes and any issues that need to be addressed.

To create a pipeline for deploying Python apps to Azure App Service, go to your project page and select Pipelines from the left navigation. Open Pipelines from Azure DevOps to run Automation PipelineClick on Create Pipeline and choose GitHub as your source code repository. Select the repository that contains your app, and install the Azure Pipelines extension when prompted. 

Choose Python to Linux Web App on Azure on the Configure your pipeline screen, and select your Azure subscription. Select Repository to run Azure PipelineApprove and Install the selected repositoryValidate and configure the pipeline to create an azure-pipelines.yml file that defines your CI/CD pipeline. Review the pipeline to ensure all default inputs are appropriate for your code.

YAML pipeline is an Azure DevOps feature that helps automate build, test, and deployment tasks. The pipeline is defined in a YAML file, which contains several key elements such as triggers, variables, stages, and steps.

To run the pipeline, save your changes in the editor and select “Run” in the pipeline editor. The pipeline may take a few minutes to complete, especially during the deployment steps, but you should see green checkmarks next to each step when it’s done. If there’s an error, you can quickly return to the YAML editor to make corrections.Select Run in the pipeline editorOnce the pipeline is complete, you can view the output of the Azure Web App task to see the deployed site. If you’re using the Flask example, it should appear in your browser.output of the Azure Web App taskStep 5: Run Automated tests: To run tests on your app code as part of your build process, you need to install dependencies into a virtual environment on the build agent computer. After the tests run, you should delete the virtual environment before creating the .zip file for deployment. The following YAML script elements illustrate this process:

- script: | 
python3.7 -m venv .env
source .env/bin/activate
pip3.7 install setuptools
pip3.7 install -r requirements.txt
displayName: 'Install dependencies on build agent'


- script: |
# Put commands to run tests here
displayName: 'Run tests'


- script: |
echo Deleting .env
deactivate
rm -rf .env
displayName: 'Remove .env before zip'

To make test results appear in the pipeline results screen, use the PublishTestResults@2 task. To run tests with pytest and collect coverage metrics with pytest-cov, use the following YAML:

- script: |
pip install pytest pytest-azurepipelines
pip install pytest-cov
pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml
displayName: 'pytest'

To run tests with Tox, use the following YAML:

- job:
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version)'
inputs:
versionSpec: '$(python.version)'
- script: pip install tox
displayName: 'Install Tox'
- script: tox -e py
displayName: 'Run Tox'

Step 6: Iterate and improve: After the initial pipeline is set up and tested, it’s important to iterate and improve the process. This involves identifying areas for improvement, such as adding more tests or optimizing the pipeline configuration, and making changes as needed.

There are multiple different ways to approach infrastructure provisioning, application development, DevOps and testing methodologies on Microsoft’s Azure.

Best practices for Azure Automated Testing

  • Use an Agile development approach: Agile methodologies emphasize frequent testing and continuous feedback. This allows issues to be identified and addressed early in the development process, reducing the likelihood of bugs in the final product.
  • Choose the right testing tools: Choose the right testing tools that are compatible with Azure, such as Azure DevOps or Azure Test Plans, and select tools like BrowserStack, that are suitable for various types of testing that has to be performed.
  • Create a reliable testing environment: A reliable testing environment ensures that the tests run in a consistent and predictable way. This includes ensuring that the infrastructure is properly configured and that the test environment closely resembles the production environment.
  • Automate as many tests as possible: Automation is a critical component of Azure Automated Testing. Automate as many tests as possible, including unit tests, integration tests, and functional tests. Automation reduces the time and effort required to run tests and allows for quicker feedback.
  • Perform regular regression testing: Regression testing ensures that new code changes do not break existing functionality. This is especially important for large or complex applications, as it can be difficult to manually test every possible scenario. Also, running tests on as many devices and operating scenarios as possible.
  • Test on Real Devices and Browsers: To get more accurate test results it is recommended to run your tests on real mobile and desktop devices, and real browsers and take real user conditions into account while testing. BrowserStack allows you to integrate your Azure DevOps Pipeline and test on 3000+ real browser-device combinations.

Integrate Azure DevOps with BrowserStack to test on Real Devices

Run Azure Pipelines on BrowserStack to test on real devices

  • Monitor test results: Monitor test results to ensure that tests are running correctly and to quickly identify any issues. Use dashboards and reports to track the progress of testing, identify trends, and identify areas for improvement.
  • Implement security testing: Security testing is critical for identifying potential security vulnerabilities in an application. Implementing security testing as part of the testing process can help identify and address these vulnerabilities before they are exploited.
  • Continuous Integration and Continuous Delivery (CI/CD): Implementing a CI/CD pipeline can automate the build, test, and deployment process. This can help reduce the time it takes to get new code changes into production and ensure that changes are thoroughly tested before being released.

By following these best practices, organizations can ensure that their Azure Automated Testing process is efficient, effective, and delivers high-quality software.

Microsoft’s focus on open-source development and collaboration has also helped to foster a vibrant and engaged community of developers around its products and services. 

Overall, it’s clear that developers have still a lot to explore with Azure cloud and automation services. BrowserStack hybrid cloud provides seamless integration options for you to expand your testing suite to many real devices through the cloud.

Tags
CI CD Tools DevOps

Featured Articles

Automated Testing with Azure DevOps: Tutorial

How to implement a Continuous Testing strategy for DevOps?

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.