Subscribe to the feed

In the modern era of cloud computing, deploying and managing resources efficiently is critical for organizations aiming to innovate quickly. With its robust suite of services like machine learning (ML) models, cognitive APIs and AI-powered applications, Azure AI has become popular for businesses looking to harness artificial intelligence (AI). However, manual deployment and management of these resources can be time-consuming and error-prone. This is where Red HatAnsible Automation Platform comes into play.

This blog explores how you can take advantage of Ansible Automation Platform to automate the deployment of Azure AI resources, create Azure Subscription Aliases and handle advanced tasks like deploying Azure OpenAI models.

Overview of Azure AI services

Azure AI offers a comprehensive suite of services to empower businesses with intelligent capabilities. These include:

  • Cognitive Services: Prebuilt APIs for natural language processing, computer vision and speech recognition
  • Machine learning: Tools for building, training and deploying custom AI models at scale
  • Azure OpenAI Service: Access to state-of-the-art language models like GPT for advanced AI-powered applications

These services enable organizations to innovate rapidly, enhance decision-making and create more intelligent applications.

Why automate Azure AI resource deployment?

1. Consistency

Manually deploying Azure AI services often leads to configuration drift, errors and inconsistencies. Automation enables repeatable, error-free deployment processes.

2. Efficiency

Automating deployments significantly reduces the time and effort required to configure resources. With Ansible Automation Platform, you can set up multiple Azure AI resources simultaneously.

3. Scalability

As your organization grows, managing many Azure AI resources manually becomes unsustainable. Automation enables you to scale your infrastructure with minimal additional effort.

Ansible Automation Platform overview

In IT automation, Ansible Automation Platform stands out as a robust solution for simplifying tasks and managing complex systems. With Ansible Automation Platform 2.x, automation workflows have become more streamlined and efficient. Its key features include:

Agentless architecture: No need to install additional software on managed nodes

YAML playbooks: Intuitive, human-readable scripts for defining tasks

Idempotency: Enables tasks to produce the same outcome regardless of how often they’re executed

Integration with Azure: Built-in modules to manage Azure resources efficiently

Preparing for Azure AI deployment with Ansible Automation Platform

Some critical preparatory steps must be followed to successfully automate Azure AI resource deployment using Ansible Automation Platform. These steps prepare and configure the environment for efficient deployment.

  1. Creating or preparing an Azure subscription.
  2. Assigning necessary permissions to Ansible Automation Platform.
  3. Understanding the Azure AI resources that can be deployed using Ansible Automation Platform.

Deploying Azure Subscriptions with Ansible Automation Platform

We can use an existing Azure subscription with the necessary permissions to deploy Azure AI resources. We can even deploy a new subscription using Ansible Automation Platform to deploy a new subscription.

Ansible Automation Platform allows for CRUD (Create, Read, Update, Delete) operations on Azure Subscription Aliases. This can help organizations automate the subscription onboarding, allowing more extensive resource deployments.

Azure Subscription Alias creation

An Azure Subscription Alias acts as a placeholder for a subscription, which includes configuration details like:

  • Billing scope
  • Subscription owner
  • Policy settings

Here’s an example playbook for creating an Azure Subscription Alias:

---
- name: Create a subscription alias
 ansible.builtin.uri:
   url: "https://management.azure.com/providers/Microsoft.Subscription/aliases/{{ subs_alias }}?api-version={{ subs_api }}"
   method: PUT
   headers:
     Authorization: "Bearer {{ invoke_response.json.access_token }}"
     Content-Type: application/json
   body:
     {
         "properties": {
             "billingScope": "{{ billing_scope }}",
             "displayName": "{{ azure_sub_resource_name }}",
             "workLoad": "Production",
             "resellerId": null,
             "additionalProperties": {
                 "managementGroupId": "",
                 "subscriptionTenantId": "{{ tenant_id }}",
                 "subscriptionOwnerId": "{{ subscription_owner_id }}",
                 "tags": {}
             }
         }
     }
   body_format: json

Understanding key variables

Billing scope:

Defines the billing account for the subscription. Find it in Azure Portal → Cost Management + Billing → Billing Accounts, and use the Resource ID (e.g., /providers/Microsoft.Billing/billingAccounts/XXXX-XXXX-XXXX).

Owners:

Specifies users or service principals managing the subscription. Use their email addresses (e.g., user@domain.com) or object IDs from Azure Active Directory.

Once the alias is created, Azure will promote it to a full subscription, enabling its use for deploying resources.


Deploying Azure AI resources with Ansible Automation Platform

Automating Azure AI resource deployments with Ansible Automation Platform aims to simplify and accelerate the provisioning of complex AI services, enabling consistency and scalability. By taking advantage of Ansible Automation Platform, organizations can deploy Azure AI resources programmatically, reducing manual effort and minimizing configuration errors. This approach makes integrating powerful AI capabilities into applications and workflows easier.

Ansible Automation Platform supports deploying various Azure AI resources, such as:

  • Azure AI Content Safety: Protect applications from harmful content
  • Azure AI ML (machine learning): Manage ML models and workflows
  • Azure AI Search: Add intelligent search capabilities to applications
  • Azure Document Intelligence: Automate document processing and extraction
  • Azure OpenAI: Enable access to generative AI models, like GPT
  • Azure OpenAI model deployments: Create specific configurations for OpenAI models
  • Azure Text Analytics: Extract insights like sentiment and key phrases from the text

While all these resources can be deployed using Ansible Automation Platform, let’s focus on 2 key examples to demonstrate how Ansible Automation Platform can accelerate AI adoption.

Example 1: Deploying a Cognitive Services resource

Cognitive Services, such as the Text Analytics API, offer powerful tools for natural language processing, enabling tasks like sentiment analysis and entity recognition. Automating the deployment of these services ensures quick and consistent access to AI capabilities across projects.

Goal: Deploy a Cognitive Services account (e.g., for Text Analytics) to a specific resource group and region. This creates an endpoint that can be used programmatically, allowing developers to integrate the service consistently into their applications.

Below is an example playbook to deploy a Cognitive Services account, such as a Text Analytics:

---
- name: Deploy Azure AI Resources
 hosts: localhost
 Tasks:
- name: Create a resource group
 azure.azcollection.azure_rm_resourcegroup:
   name: "{{ resource_group_name }}"
   location: "{{ location }}"
   tags:
     tag1: value1
     tag2: value2
 register: resource_group_result
- name: Create Azure Document Intelligence Resource
 azure.azcollection.azure_rm_resource:
   state: present
   resource_group: "{{ resource_group_name }}"
   provider: CognitiveServices
   resource_type: accounts
   resource_name: "{{ resource_name }}"
   body:
     kind: FormRecognizer
     location: "{{ location }}"
     sku:
       name: "{{ sku_name }}"
     tags: "{{ resource_tags }}"

You can use Ansible Automation Platform to create a project and template to run this playbook. Ansible Automation Platform provides a centralized interface to manage and execute playbooks efficiently. Learn more about working with Ansible Automation Platform today.

Example:

Cognitive Services resource

Also, you can test this from your CLI:

ansible-playbook azure_ai_deploy.yml -e "resource_group='example_rg' resource_name=example_resource location='East US' sku=S0

Deploying Azure OpenAI models using ansible.builtin.uri

Azure OpenAI provides access to advanced generative AI (gen AI) models like GPT. These models unlock possibilities such as text summarization, chatbot integration and creative content generation. Automating the deployment of OpenAI models gives users rapid access to these capabilities while reducing operational complexity.

Goal: Deploy an Azure OpenAI model to a specific endpoint using Ansible Automation Platform’s URI module, enabling applications to interact with the model via REST API calls.

Example: Deploying Azure OpenAI models

Key details:

  • Access token: Ensure you authenticate and retrieve an access token using Azure CLI or another method
  • REST API integration: The playbook uses Azure REST API endpoints for direct resource configuration

Here’s how you might use the URI module to deploy an OpenAI model in an Ansible Playbook:

---
- name: Deploy Azure OpenAI Model
 ansible.builtin.uri:
   url: "{{ azure_openai_model_cognitive_uri }}/deployments/{{ azure_openai_model_deployment_name }}?api-version={{ azure_openai_model_api_version }}"
   method: PUT
   headers:
     Content-Type: application/json
     Authorization: "{{ azure_rest_auth_bearer }}"
   body_format: json
   body:
     sku:
       name: "{{ sku_name }}"
       capacity: "{{ azure_openai_model_capacity }}"
     properties:
       raiPolicyName: "{{ rai_policy_name }}"
       model:
         format: "{{ azure_openai_model_format }}"
         name: "{{ azure_openai_model_name }}"
         version: "{{ azure_openai_model_version }}"

Recommended practices for automating Azure AI deployments

These are the best practices our team has found as we work on deploying AI services on Azure:

  1. Modular playbooks: Break down complex playbooks into reusable roles for modularity
  2. Secure credentials: Use Ansible Vault to store sensitive Azure credentials securely
  3. Test in non-production: Always test deployments in a staging environment before rolling them out to production
  4. Logging and monitoring: Enable detailed logs to track deployment statuses and troubleshoot issues quickly
  5. Integrate with CI/CD pipelines: Use tools like Jenkins or GitHub Actions to automate and schedule deployments

Benefits of using Ansible Automation Platform for Azure AI

By taking advantage of Ansible Automation Platform for Azure AI, you can unlock several key advantages:

  • Unified automation: Automate not just AI resource deployment but also the provisioning of Azure subscriptions
  • Enhanced flexibility: Use REST APIs (ansible.builtin.uri) for advanced deployments like OpenAI models
  • Community support: Take advantage of the vast Ansible community and Azure documentation for ongoing support and improvements
  • Cost optimization: Reduce manual intervention and errors, saving time and operational costs

Conclusion

Organizations can achieve consistency, scalability and efficiency by automating the deployment of Azure AI resources with Ansible Automation Platform. Whether deploying a Cognitive Services API, creating a subscription alias or configuring an Azure OpenAI model, Ansible Automation Platform makes the process streamlined and repeatable.

Ready to simplify your Azure deployments? Start building your Ansible Playbooks today, and watch your operations become more efficient.

Learn more

product trial

Red Hat Ansible Automation Platform | Product Trial

An agentless automation platform.

About the author

Sohidur Rahman is a dedicated Red Hat Senior Consultant, driven by a passion for helping clients overcome their strategic technology and business challenges using open source methods and technologies.

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Keep exploring

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech