Blog Post

Azure Architecture Blog
12 MIN READ

AI for Operations

TaleTom's avatar
TaleTom
Icon for Microsoft rankMicrosoft
Dec 10, 2024

An integrated framework leveraging Azure OpenAI,Logic Apps and Azure Fuctions to optimize operational processes, including cost monitoring, anomaly detection, security updates, and database assessments, with seamless scalability and intelligence for modern cloud environments.

Solutions idea

This solution series shows some examples of how Azure OpenAI and its LLM models can be used on Operations and FinOps issues. With a view to the use of models linked to the Enterprise Scale Landing Zone, the solutions shown, which are available on a dedicated GitHub, are designed to be deployed within a dedicated subscription, in the examples called ‘OpenAI-CoreIntegration’.  The examples we are going to list are:

  • SQL BPA AI Enhanced
  • Azure Update Manager AI Enhanced
  • Azure Cost Management AI Enhanced
  • Azure AI Anomalies Detection
  • Azure OpenAI Smart Doc Creator

Enterprise Scale AI for Operations Landing Zone Design Architecture

 

SQL BPA AI Enhanced Architecture

This LogApp is an example of integrating ARC SQL practices assessment results with OpenAI, creating an HTML report and CSV file send via Email with OpenAI comment of Severity High and/or Medium results based on the actual Microsoft Documentation. 

Dataflow

Initial Trigger
  • Type: Recurrence
  • Configuration:
    • Frequency: Weekly
    • Day: Monday
    • Time: 9:00 AM
    • Time Zone: W. Europe Standard Time
  • Description: The Logic App is triggered weekly to gather data for SQL Best Practice Assessments.
Step 1: Data Query
  • Action: Run_query_and_list_results
  • Description: Executes a Log Analytics query to retrieve SQL assessment results from monitored resources.
  • Output: A dataset containing issues classified by severity (High/Medium).
Step 2: Variable Initialization
  • Actions:
    • Initialize_variable_CSV: Initializes an empty array to store CSV results.
    • Open_AI_API_Key: Sets up the API key for Azure OpenAI service.
    • HelpLinkContent: Prepares a variable to store useful links.
  • Description: Configures necessary variables for subsequent steps.
Step 3: Process Results
  • Action: For_eachSQLResult
  • Description: Processes the query results with the following sub-steps:
    • Condition: Checks if the severity is High or Medium.
    • OpenAI Processing:
      • Sends structured prompts to the GPT-4 model for recommendations on identified issues.
      • Parses the JSON response to extract specific insights.
    • CSV Composition: Creates an array containing detailed results.
Step 4: Report Generation
  • Actions:
    • Create_CSV_table: Converts processed data into a CSV format.
    • Create_HTML_table: Generates an HTML table from the data.
    • ComposeMailMessage: Prepares an HTML email message containing the results and a link to the report.
  • Description: Formats the data for sharing.
Step 5: Saving and Sharing
  • Actions:
    • Create_file: Saves the HTML report to OneDrive.
    • Send_an_email_(V2): Sends an email with the reports attached (HTML and CSV).
    • Post_message_in_a_chat_or_channel: Shares the results in a Teams channel.
  • Description: Distributes the reports to defined recipients.

Components

  • Azure OpenAI service is a platform provided by Microsoft that offers access to powerful language models developed by OpenAI, including GPT-4, GPT-4o, GPT-4o mini, and others. The service is used in this scenario for all the natural language understanding and generating communication to the customers.
  • Azure Logic Apps is a cloud platform where you can create and run automated workflows with little to no code.
  • Azure Logic Apps Managed Identities allow to authenticate to any resource that supports Microsoft Entra authentication, including your own applications.
  • Azure Bing Web Search enables safe, ad-free, location-aware search results, surfacing relevant information from billions of web documents. Help your users find what they're looking for from the world-wide-web by harnessing Bing's ability to comb billions of webpages, images, videos, and news with a single API call.
  • Azure ARC SQL Server enabled by Azure Arc extends Azure services to SQL Server instances hosted outside of Azure: in your data center, in edge site locations like retail stores, or any public cloud or hosting provider.
  • SQL Best Practices Assessment feature provides a mechanism to evaluate the configuration of your SQL Server instance.
  • Azure Monitor is a comprehensive monitoring solution for collecting, analyzing, and responding to monitoring data from your cloud and on-premises environments.
  • Azure Kusto Queryis a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more

Potential use cases

SQL BPA AI Enhanced exploits the capabilities of the SQL Best Practice Assessment service based on Azure ARC SQL Server. The collected data can be used for the generation of customised tables. The solution is designed for customers who want to enrich their Assessment information with Generative Artificial Intelligence.

 

Azure Update Manager AI Enhanced Architecture

This LogApp solution example retrieves data from the Azure Update Manager service and returns an output processed by generative artificial intelligence.

Dataflow

Initial Trigger
  • Type: Recurrence Trigger
  • Frequency: Monthly
  • Time Zone: W. Europe Standard Time
  • Triggers the Logic App at the beginning of every month.
Step 1: Initialize API Key
  • Action: Initialize Variable
  • Variable Name: Api-Key
Step 2: Fetch Update Status
  • Action: HTTP Request
  • URI: https://management.azure.com/providers/Microsoft.ResourceGraph/resources
  • Query: Retrieves resources related to patch assessments using patchassessmentresources.
Step 3: Parse Update Status
  • Action: Parse JSON
  • Content: Response body from the HTTP request.
  • Schema: Extracts details such as VM Name, Patch Name, Patch Properties, etc.
Step 4: Process Updates

For Each: Body('Parse_JSON')?['data']

  • Iterates through each item in the parsed update data.

Condition: If Patch Name is not null and contains "KB":

  1. Action: Format Item
    • Parses individual update items for VM Name, Patch Name, and additional properties.
  2. Action: Send to Azure OpenAI
    • Description: Sends structured prompts to the GPT-4 model
    • Headers:
      • Content-Type: application/json
      • api-key: @variables('Api-Key')
    • Body:
      • Prompts Azure OpenAI to generate a report for each virtual machine and patch, formatted in Italian.
  3. Action: Parse OpenAI Response
    • Extracts and formats the response generated by Azure OpenAI.
  4. Action: Append to Summary and CSV
    • Adds the OpenAI-generated response to the Updated Summary array.
    • Appends patch details to the CSV array.
Step 5: Finalize Report
  1. Action: Create Reports (I, II, III)
    • Formats and cleans the Updated Summary variable to remove unwanted characters.
  2. Action: Compose HTML Email Content
    • Constructs an HTML email with the following:
      • Report summary generated using OpenAI.
      • Disclaimer about possible formatting anomalies.
      • Company logo embedded.
Step 6: Generate CSV Table
  • Action: Converts the CSV array into a CSV format for attachment.
Step 7: Send E-Mail
  1. Action: Send Email
    • Recipient: user@microsoft.com
    • Subject: Security Update Assessment
    • Body: HTML content with report summary.
    • Attachment:
      • Name: SmartUpdate_<timestamp>.csv
      • Content: CSV table of update details.

Components

  • Azure OpenAI service is a platform provided by Microsoft that offers access to powerful language models developed by OpenAI, including GPT-4, GPT-4o, GPT-4o mini, and others. The service is used in this scenario for all the natural language understanding and generating communication to the customers.
  • Azure Logic Apps is a cloud platform where you can create and run automated workflows with little to no code.
  • Azure Logic Apps Managed Identities allow to authenticate to any resource that supports Microsoft Entra authentication, including your own applications.
  • Azure Update Manager is a unified service to help manage and govern updates for all your machines. You can monitor Windows and Linux update compliance across your machines in Azure and on-premises/on other cloud platforms (connected by Azure Arc) from a single pane of management. You can also use Update Manager to make real-time updates or schedule them within a defined maintenance window.
  • Azure Arc Server lets you manage Windows and Linux physical servers and virtual machines hosted outside of Azure, on your corporate network, or other cloud provider.

Potential use cases

Azure Update Manager AI Enhanced is an example of a solution designed for all those situations where the IT department needs to manage and automate the telling of information in a readable format on the status of updates to its infrastructure thanks to an output managed by generative artificial intelligence

Azure Cost Management AI Enhanced Architecture

This LogApp solution retrieves consumption data from the Azure environment and generates a general and detailed cost trend report on a scheduled basis.

Dataflow

Initial Trigger
  • Type: Manual HTTP Trigger
  • The Logic App is triggered manually using an HTTP request.
Step 1: Set Current Date and Old Date
  1. Action: Set Actual Date
    • Current date is initialized to @utcNow('yyyy-MM-dd').
    • Example Value: 2024-11-22.
  2. Action: Set Actual Date -30
    • Old date is set to 30 days before the current date.
    • Example Value: 2024-10-23.
  3. Action: Set old date -30
    • Sets the variable currentdate to 30 days prior to the old date.
    • Example Value: 2024-09-23.
  4. Action: Set old date -60
    • Sets the variable olddate to 60 days before the current date.
    • Example Value: 2024-08-23.
Step 2: Query Cost Data
  1. Action: Query last 30 days
    • Queries Azure Cost Management for the last 30 days.
    • Example Data Returned:json{ "properties": { "rows": [ ["Virtual Machines", 5000], ["Databases", 7000], ["Storage", 3000] ] } }
    • Copia codice
  2. Action: Query -60 -30 days
    • Queries Azure Cost Management for 30 to 60 days ago.
    • Example Data Returned:json{ "properties": { "rows": [ ["Virtual Machines", 4800], ["Databases", 6800], ["Storage", 3050] ] } }
    • Copia codice
Step 3: Download Detailed Reports
  1. Action: Download_report_actual_month
    • Generates and retrieves a detailed cost report for the current month.
  2. Action: Download_report_last_month
    • Generates and retrieves a detailed cost report for the previous month.
Step 4: Process and Store Reports
  1. Action: Actual_Month_Report
    • Parses the JSON from the current month's report.
    • Retrieves blob download links for the detailed report.
  2. Action: Last_Month_Report
    • Parses the JSON from the last month's report.
    • Retrieves blob download links for the detailed report.
  3. Action: Create_ActualMonthDownload and Create_LastMonthDownload
    • Initializes variables to store download links.
  4. Action: Get_Actual_Month_Download_Link and Get_Last_Month_Download_Link
    • Iterates through blob data and assigns the download link variables.
Step 5: Generate Questions for OpenAI
  1. Action: Set_Question
    • Prepares the first question for Azure OpenAI: "Describe the key differences between the previous and current month's costs, and create a bullet-point list detailing these differences in Euros."
  2. Action: Set_Second_Question
    • Prepares a second question for Azure OpenAI: "Briefly describe in Italian the major cost differences between the two months, rounding the amounts to Euros."
Step 6: Send Questions to Azure OpenAI
  1. Action: Passo result to OpenAI
    • Sends the first question to OpenAI for generating detailed insights.
  2. Action: Get Description from OpenAI
    • Sends the second question to OpenAI for a brief summary in Italian.
Step 8: Process OpenAI Responses
  1. Action: Parse_JSON and Parse_JSON_Second_Question
    • Parses the JSON response from OpenAI for both questions.
    • Retrieves the content of the generated insights.
  2. Action: For_each_Description
    • Iterates through OpenAI's responses and assigns the description to a variable DescriptionOutput.

Step 9: Compose and send E-Mail

  1. Action: Compose_Email
    • Composes an HTML email including:
      • Key insights from OpenAI.
      • Links to download the detailed reports.
    • Example Email Content: Azure automated cost control system: - Increase of €200 in Virtual Machines. - Reduction of €50 in Storage. Download details: - Current month: [Download Report] - Previous month: [Download Report].
  2. Action: Send_an_email_(V2)
    • Sends the composed email.

Components

  • Azure OpenAI service is a platform provided by Microsoft that offers access to powerful language models developed by OpenAI, including GPT-4, GPT-4o, GPT-4o mini, and others. The service is used in this scenario for all the natural language understanding and generating communication to the customers.
  • Azure Logic Apps is a cloud platform where you can create and run automated workflows with little to no code.
  • Azure Logic Apps Managed Identities allow to authenticate to any resource that supports Microsoft Entra authentication, including your own applications.

Potential use cases

Azure Cost Management AI Enhanced is an example of a solution designed for those who need to programme the generation of reports related to FinOps topics with the possibility to customise the output and send the results via e-mail or perform a customised upload.

Azure AI Anomalies Detection Architecture

This LogApp solution leverages Azure Monitor's native machine learning capabilities to retrieve anomalous data within application logs. These will then be analysed by OpenAI.

Dataflow

Initial Trigger
  • Type: Recurrence Trigger
  • Frequency: Monthly
  • Time Zone: W. Europe Standard Time
  • Triggers the Logic App at the beginning of every month.
Step 1: Initialize API Key
  • Action: Initialize Variable
  • Variable Name: Api-Key
Step 2: Fetch Update Status
  • Action: HTTP Request
  • URI: https://management.azure.com/providers/Microsoft.ResourceGraph/resources
  • Query: Retrieves resources related to patch assessments using patchassessmentresources.
Step 3: Parse Update Status
  • Action: Parse JSON
  • Content: Response body from the HTTP request.
  • Schema: Extracts details such as VM Name, Patch Name, Patch Properties, etc.
Step 4: Process Updates

For Each: @body('Parse_JSON')?['data']

  • Iterates through each item in the parsed update data.

Condition: If Patch Name is not null and contains "KB":

  1. Action: Format Item
    • Parses individual update items for VM Name, Patch Name, and additional properties.
  2. Action: Send to Azure OpenAI
    • Description: Sends structured prompts to the GPT-4 model.
    • Headers:
      • Content-Type: application/json
      • api-key: @variables('Api-Key')
    • Body:
      • Prompts Azure OpenAI to generate a report for each virtual machine and patch, formatted in Italian.
  3. Action: Parse OpenAI Response
    • Extracts and formats the response generated by Azure OpenAI.
  4. Action: Append to Summary and CSV
    • Adds the OpenAI-generated response to the Updated Summary array.
    • Appends patch details to the CSV array.
Step 5: Finalize Report
  1. Action: Create Reports (I, II, III)
    • Formats and cleans the Updated Summary variable to remove unwanted characters.
  2. Action: Compose HTML Email Content
    • Constructs an HTML email with the following:
      • Report summary generated using OpenAI.
      • Disclaimer about possible formatting anomalies.
      • Company logo embedded.
Step 6: Generate CSV Table
  • Action: Converts the CSV array into a CSV format for attachment.
Step 7: Send Notifications
  1. Action: Send Email
    • Recipient: user@microsoft.com
    • Subject: Security Update Assessment
    • Body: HTML content with report summary.
    • Attachment:
      • Name: SmartUpdate_<timestamp>.csv
      • Content: CSV table of update details.

Components

  • Azure OpenAI service is a platform provided by Microsoft that offers access to powerful language models developed by OpenAI, including GPT-4, GPT-4o, GPT-4o mini, and others. The service is used in this scenario for all the natural language understanding and generating communication to the customers.
  • Azure Logic Apps is a cloud platform where you can create and run automated workflows with little to no code.
  • Azure Logic Apps Managed Identities allow to authenticate to any resource that supports Microsoft Entra authentication, including your own applications.
  • Azure Monitor is a comprehensive monitoring solution for collecting, analyzing, and responding to monitoring data from your cloud and on-premises environments.
  • Azure Kusto Queryis a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more

Potential use cases

Azure AI Anomalies Detection is an example of a solution that exploits the Machine Learning capabilities of Azure Monitor to diagnose anomalies within application logs that will then be analysed by Azure OpenAI. The solution can be customized based on Customer requirements.

 

Azure OpenAI Smart Doc Creator Architecture

This Function App solution leverages the Azure OpenAI LLM Generative AI to create a docx file based on the Azure architectural information of a specific workload (Azure Metadata based). The function exploits the 'OpenAI multi-agent' concept.

Dataflow

Step 1: Logging and Configuration Setup
  • Initialize Logging:
    • Advanced logging is set up to provide debug-level insights.
    • Format includes timestamps, log levels, and messages.
  • Retrieve OpenAI Endpoint:
    • QUESTION_ENDPOINT is retrieved from environment variables.
    • Logging confirms the endpoint retrieval.
Step 2: Authentication
  • Managed Identity Authentication:
    • The ManagedIdentityCredential class is used for secure Azure authentication.
    • The SubscriptionClient is initialized to access Azure subscriptions.
    • Retrieves a token for Azure Cognitive Services (https://cognitiveservices.azure.com/.default).
Step 3: Flattening Dictionaries
  • Function: flatten_dict
    • Transforms nested dictionaries into a flat structure.
    • Handles nested lists and dictionaries recursively.
    • Used for preparing metadata for storage in CSV.
Step 4: Resource Tag Filtering
  • Functions:
    • get_resources_by_tag_in_subscription: Filters resources in a subscription based on a tag key and value.
    • get_resource_groups_by_tag_in_subscription: Identifies resource groups with matching tags.
  • Purpose: Retrieve Azure resources and resource groups tagged with specific key-value pairs.
Step 5: Resource Metadata Retrieval
  • Functions:
    • get_all_resources: Aggregates resources and resource groups across all accessible subscriptions.
    • get_resources_in_resource_group_in_subscription: Retrieves resources from specific resource groups.
    • get_latest_api_version: Determines the most recent API version for a given resource type.
    • get_resource_metadata: Retrieves detailed metadata for individual resources using the latest API version.
  • Purpose: Collect comprehensive resource details for further processing.
Step 6: Documentation Generation
  • Function: generate_infra_config
    • Processes metadata through OpenAI to generate documentation.
    • OpenAI generates detailed and human-readable descriptions for Azure resources.
    • Multi-stage review process:
      • Initial draft by OpenAI.
      • Feedback loop with ArchitecturalReviewer and DocCreator for refinement.
    • Final content is saved to architecture.txt.
Step 7: Workload Overview
  • Function: generate_workload_overview
    • Reads from the generated CSV file to create a summary of the workload.
    • Sends resource list to OpenAI for generating a high-level overview.
Step 8: Conversion to DOCX
  • Function: txt_to_docx
    • Creates a Word document (Output.docx) with:
      • Section 1: "Workload Overview" (generated summary).
      • Section 2: "Workload Details" (detailed resource metadata).
    • Adds structured headings and page breaks.
Step 9: Temporary Files Cleanup
  • Function: cleanup_files
    • Deletes temporary files:
      • architecture.txt
      • resources_with_expanded_metadata.csv
      • Output.docx
    • Ensures no residual files remain after execution.
Step 10: CSV Metadata Export
  • Function: save_resources_with_expanded_metadata_to_csv
    • Aggregates and flattens resource metadata.
    • Saves details to resources_with_expanded_metadata.csv.
    • Includes unique keys derived from all metadata fields.
Step 11: Architectural Review Process
  • Functions:
    • ArchitecturalReviewer: Reviews and suggests improvements to documentation.
    • DocCreator: Incorporates reviewer suggestions into the documentation.
  • Purpose: Iterative refinement for high-quality documentation.
Step 12: HTTP Trigger Function
  • Function: smartdocs
    • Accepts HTTP requests with tag_key and tag_value parameters.
    • Orchestrates the entire workflow:
      • Resource discovery.
      • Metadata retrieval.
      • Documentation generation.
      • File cleanup.
    • Responds with success or error messages.

Components

  • Azure OpenAI service is a platform provided by Microsoft that offers access to powerful language models developed by OpenAI, including GPT-4, GPT-4o, GPT-4o mini, and others. The service is used in this scenario for all the natural language understanding and generating communication to the customers.
  • Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.
  • Azure Function App Managed Identities allow to authenticate to any resource that supports Microsoft Entra authentication, including your own applications.
  • Azure libraries for Python (SDK) are the open-source Azure libraries for Python designed to simplify the provisioning, management and utilisation of Azure resources from Python application code.

Potential use cases

The Azure OpenAI Smart Doc Creator Function App, like all proposed solutions, can be modified to suit your needs. It can be of practical help when there is a need to obtain all the configurations, in terms of metadata, of the resources and services that make up a workload.

 

Contributors

Principal author:

Extended Contribution:

Special Thanks:

Updated Dec 18, 2024
Version 3.0
  • ChrisForjahn's avatar
    ChrisForjahn
    Copper Contributor

    Are these examples available in GitHub? I would like to try them in my lab. 
    Thanks, Chris