PowerShellMicrosoft GraphPHP Azure

Azure AI Model Deployment Automation

Repository to manage Azure AI resources using Microsoft Graph API with PowerShell and PHP.

📖 Read Full Engineering Guide → 🐙 GitHub Repo
### FILE: index.php
<?php

// Placeholder for access token from session
$accessToken = $_SESSION['ms_access_token'];

// Function to call the Azure AI resource model endpoint and deploy an AI model
function deployAIModel($modelName) {
    global $ms, $accessToken;
    $endpoint = "https://graph.microsoft.com/v1.0/resourceModel";
    $body = [
        'modelName' => $modelName
    ];
    $response = $ms->graphCall($endpoint, $accessToken, 'POST', $body);

    if ($response) {
        render_premium_card("Model Deployment", "Model $modelName deployed successfully", null, 'up', '🚀', 100);
    } else {
        echo "Error deploying model.";
    }
}

// Calling function to deploy the model
$modelName = "ContosoAI";
deployAIModel($modelName);

?>

### FILE: scripts/Automation.ps1
<#
.SYNOPSIS
   Deploys an AI model using Microsoft Graph API.
.DESCRIPTION
   This script integrates with the Microsoft Graph API to manage Azure AI resources, specifically to deploy an AI model.
.EXAMPLE
   Deploy-AIModel -modelName 'ContosoAI'
.NOTES
   Author:      Souhaiel Morhag
   Company:     MSEndpoint.com
   Blog:        https://msendpoint.com
   Academy:     https://app.msendpoint.com/academy
   LinkedIn:    https://linkedin.com/in/souhaiel-morhag
   GitHub:      https://github.com/Msendpoint
   License:     MIT
#>

Import-Module Microsoft.Graph

# Connect to Microsoft Graph with necessary scopes
Connect-MgGraph -Scopes "AI.ReadWrite.All", "Directory.Read.All"

function Deploy-AIModel {
    [CmdletBinding(SupportsShouldProcess=$true)]
    Param (
        [Parameter(Mandatory=$true)]
        [string]$modelName
    )

    Try {
        # Invoke Graph API to deploy AI model
        Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/v1.0/resourceModel" `
          -Method POST `
          -Body @{modelName = $modelName} | Out-Null
        Write-Output "Model $modelName deployed successfully"
    } Catch {
        # Error handling for failed deployment
        Write-Error "Error deploying model: $_.Exception.Message"
        exit 1
    }
}

# Example of deploying an AI model
Deploy-AIModel -modelName "ContosoAI" -WhatIf

⚠️ Always review and validate PowerShell scripts in a non-production pilot group before tenant-wide deployment.

🎓 Preparing for MD-102, SC-300, AZ-104 or AB-650?

Practice 1,060+ Microsoft Learn-verified exam questions in Pearson VUE simulator mode.

Free MD-102 Exam → vs MeasureUp