Published on

Microsoft Enterprise AI | Azure KI-Plattform

Authors

Microsoft AI Studio: Die Enterprise-KI-Revolution

Microsofts Azure AI Studio ist die integrierte Plattform für moderne KI-Entwicklung und -Deployment. Als Nachfolger von Azure Machine Learning Studio bietet diese einheitliche Umgebung für Large Language Models (LLMs), Machine Learning und Responsible AI - perfekt für Enterprise-Anwendungen.

Kernfunktionen der Plattform:

  • Unified AI Platform - Alle KI-Workloads in einer Umgebung
  • Azure OpenAI Integration - Direkter Zugang zu GPT-4, Claude und anderen LLMs
  • Responsible AI Tools - Fairness, Transparenz und Compliance
  • MLOps Integration - End-to-End Machine Learning Lifecycle
  • Enterprise Security - Azure AD, RBAC und Compliance-Standards

Vorteile für Unternehmen:

  • +60% schnellere KI-Entwicklung
  • +40% Kosteneinsparungen durch optimierte Ressourcennutzung
  • 100% Compliance mit Enterprise-Sicherheitsstandards
  • Nahtlose Integration in bestehende Azure-Umgebungen

Warum Unternehmen auf Microsofts KI-Plattform setzen:

Die moderne KI-Entwicklung erfordert eine umfassende Plattform, die alle Aspekte des Machine Learning Lifecycles abdeckt. Von der Datenvorverarbeitung über das Modelltraining bis hin zum Production-Deployment bietet Microsofts Lösung eine einheitliche Umgebung für Enterprise-Anwendungen. Unternehmen profitieren von der nahtlosen Integration in bestehende Azure-Infrastrukturen und der umfassenden Compliance-Unterstützung für regulatorische Anforderungen.

Plattform-Architektur

System-Übersicht

# Microsoft AI Studio Architektur
azure_ai_studio:
  core_components:
    - ai_hub: Zentrale Modell-Verwaltung
    - prompt_flow: LLM-Entwicklung und -Testing
    - model_catalog: Vorfertigte Modelle und Frameworks
    - responsible_ai: Fairness und Compliance-Tools
    - mlops: Deployment und Monitoring

  data_services:
    - azure_data_lake: Skalierbare Datenspeicherung
    - azure_synapse: Analytics und Data Engineering
    - azure_databricks: Spark-basierte Verarbeitung
    - azure_cognitive_services: Pre-built AI Services

  compute_resources:
    - azure_machine_learning_compute: Managed ML-Cluster
    - azure_kubernetes_service: Container-Deployment
    - azure_container_instances: Serverless Computing
    - azure_functions: Event-driven Processing

  security_compliance:
    - azure_active_directory: Identity Management
    - azure_key_vault: Secret Management
    - azure_policy: Governance und Compliance
    - azure_monitor: Observability und Monitoring

Azure OpenAI Integration

# azure_openai_integration.py
from azure.ai.ml import MLClient
from azure.ai.ml.entities import Workspace
from azure.identity import DefaultAzureCredential
from openai import AzureOpenAI
import os

class MicrosoftAIStudioClient:
    def __init__(self, subscription_id, resource_group, workspace_name):
        self.subscription_id = subscription_id
        self.resource_group = resource_group
        self.workspace_name = workspace_name

        # Azure Credentials
        self.credential = DefaultAzureCredential()

        # ML Client für die Plattform
        self.ml_client = MLClient(
            credential=self.credential,
            subscription_id=subscription_id,
            resource_group_name=resource_group,
            workspace_name=workspace_name
        )

        # OpenAI Client
        self.openai_client = AzureOpenAI(
            azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
            api_key=os.getenv("AZURE_OPENAI_API_KEY"),
            api_version="2024-02-15-preview"
        )

    def create_workspace(self, location="westeurope"):
        """Microsoft AI Studio Workspace erstellen"""
        workspace = Workspace(
            name=self.workspace_name,
            location=location,
            display_name=f"{self.workspace_name} AI Studio",
            description="Enterprise AI Studio Workspace",
            hbi_workspace=False,
            tags={
                "environment": "production",
                "team": "ai-engineering"
            }
        )

        return self.ml_client.workspaces.begin_create(workspace).result()

    def deploy_openai_model(self, model_name="gpt-4", deployment_name=None):
        """OpenAI-Modell in der Plattform deployen"""
        if not deployment_name:
            deployment_name = f"{model_name}-deployment"

        # Deployment-Konfiguration
        deployment_config = {
            "model": model_name,
            "deployment_name": deployment_name,
            "capacity": 1,  # Standard-Kapazität
            "scale_type": "manual"
        }

        # Deployment erstellen
        deployment = self.ml_client.online_endpoints.begin_create_or_update(
            deployment_config
        ).result()

        return deployment

    def create_prompt_flow(self, flow_name, description=""):
        """Prompt Flow für LLM-Entwicklung erstellen"""
        flow_config = {
            "name": flow_name,
            "description": description,
            "type": "standard",
            "environment": "azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest"
        }

        return self.ml_client.prompt_flows.begin_create_or_update(flow_config).result()

    def test_llm_response(self, prompt, model="gpt-4", temperature=0.7):
        """LLM-Antwort testen"""
        try:
            response = self.openai_client.chat.completions.create(
                model=model,
                messages=[
                    {"role": "system", "content": "Du bist ein hilfreicher Assistent."},
                    {"role": "user", "content": prompt}
                ],
                temperature=temperature,
                max_tokens=1000
            )

            return {
                "response": response.choices[0].message.content,
                "model": model,
                "tokens_used": response.usage.total_tokens,
                "finish_reason": response.choices[0].finish_reason
            }

        except Exception as e:
            return {"error": str(e)}

    def create_responsible_ai_dashboard(self, model_name, dataset_name):
        """Responsible AI Dashboard erstellen"""
        dashboard_config = {
            "name": f"{model_name}-responsible-ai",
            "model_name": model_name,
            "dataset_name": dataset_name,
            "features": ["feature1", "feature2", "feature3"],
            "target_column": "target",
            "task_type": "classification"
        }

        return self.ml_client.responsible_ai.begin_create_or_update(dashboard_config).result()

Prompt Flow: LLM-Entwicklung revolutioniert

Visual Prompt Engineering

# prompt_flow_example.yaml
name: 'customer_service_chatbot'
description: 'Intelligenter Kundenservice-Chatbot mit Azure OpenAI'
type: 'standard'
environment: 'azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest'

nodes:
  - name: 'user_input'
    type: 'input'
    parameters:
      prompt: '{{$inputs.user_message}}'

  - name: 'context_retrieval'
    type: 'llm'
    parameters:
      model: 'gpt-4'
      prompt: |
        Analysiere die folgende Kundenanfrage und extrahiere relevante Informationen:
        {{user_input.prompt}}

        Extrahiere:
        - Anfragetyp (Support, Verkauf, Beschwerde)
        - Priorität (Niedrig, Mittel, Hoch)
        - Benötigte Informationen
    outputs:
      - context_info

  - name: 'knowledge_base_lookup'
    type: 'python'
    parameters:
      code: |
        def lookup_knowledge_base(context_info):
            # Simulierte Wissensdatenbank-Abfrage
            knowledge_base = {
                "support": "Hier sind die häufigsten Support-Lösungen...",
                "sales": "Unsere Produkte und Preise...",
                "complaint": "Beschwerde-Prozess und Kontakte..."
            }
            
            query_type = context_info.get("anfragetyp", "support")
            return knowledge_base.get(query_type, "Standard-Antwort")

        result = lookup_knowledge_base(context_info)
        return {"knowledge": result}
    inputs:
      - context_info
    outputs:
      - knowledge

  - name: 'response_generation'
    type: 'llm'
    parameters:
      model: 'gpt-4'
      prompt: |
        Basierend auf der Kundenanfrage und dem verfügbaren Wissen, 
        erstelle eine professionelle und hilfreiche Antwort:

        Kundenanfrage: {{user_input.prompt}}
        Kontext: {{context_retrieval.context_info}}
        Wissen: {{knowledge_base_lookup.knowledge}}

        Antworte freundlich und professionell.
    outputs:
      - final_response

  - name: 'response_validation'
    type: 'python'
    parameters:
      code: |
        def validate_response(response):
            # Antwort-Qualität validieren
            validation_result = {
                "is_appropriate": True,
                "sentiment": "positive",
                "confidence": 0.9,
                "suggestions": []
            }
            
            # Einfache Validierung
            inappropriate_words = ["unangemessen", "beleidigend"]
            for word in inappropriate_words:
                if word in response.lower():
                    validation_result["is_appropriate"] = False
                    validation_result["suggestions"].append(f"Vermeide: {word}")
            
            return validation_result

        result = validate_response(final_response)
        return {"validation": result}
    inputs:
      - final_response
    outputs:
      - validation_result

outputs:
  - name: 'chat_response'
    value: '{{response_generation.final_response}}'
  - name: 'confidence'
    value: '{{response_validation.validation_result.confidence}}'

Prompt Flow Python SDK

# prompt_flow_development.py
from promptflow import PFClient
from promptflow.entities import Flow
import json

class PromptFlowDeveloper:
    def __init__(self, workspace_name):
        self.pf_client = PFClient()
        self.workspace_name = workspace_name

    def create_flow_from_yaml(self, yaml_path, flow_name):
        """Flow aus YAML-Datei erstellen"""
        flow = Flow.from_yaml(yaml_path)
        flow.name = flow_name

        # Flow in der Plattform deployen
        created_flow = self.pf_client.flows.create_or_update(flow)
        return created_flow

    def test_flow(self, flow_name, inputs):
        """Flow mit Testdaten ausführen"""
        try:
            result = self.pf_client.test(flow_name, inputs=inputs)
            return {
                "success": True,
                "outputs": result.outputs,
                "execution_time": result.execution_time
            }
        except Exception as e:
            return {
                "success": False,
                "error": str(e)
            }

    def create_evaluation_flow(self, flow_name, evaluation_criteria):
        """Evaluation Flow für LLM-Performance erstellen"""
        evaluation_config = {
            "name": f"{flow_name}_evaluation",
            "description": f"Evaluation für {flow_name}",
            "type": "evaluation",
            "evaluation_criteria": evaluation_criteria
        }

        return self.pf_client.flows.create_or_update(evaluation_config)

    def run_batch_evaluation(self, flow_name, test_dataset, evaluation_flow):
        """Batch-Evaluation für Flow-Performance"""
        evaluation_results = []

        for test_case in test_dataset:
            # Flow ausführen
            flow_result = self.test_flow(flow_name, test_case["inputs"])

            if flow_result["success"]:
                # Evaluation durchführen
                eval_inputs = {
                    "expected_output": test_case["expected_output"],
                    "actual_output": flow_result["outputs"]["chat_response"],
                    "context": test_case.get("context", "")
                }

                eval_result = self.test_flow(evaluation_flow, eval_inputs)
                evaluation_results.append({
                    "test_case": test_case["id"],
                    "flow_result": flow_result,
                    "evaluation": eval_result
                })

        return evaluation_results

    def deploy_flow_as_endpoint(self, flow_name, endpoint_name):
        """Flow als API-Endpoint deployen"""
        endpoint_config = {
            "name": endpoint_name,
            "flow_name": flow_name,
            "environment": "azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest",
            "compute": "azureml:cpu-cluster"
        }

        return self.pf_client.endpoints.create_or_update(endpoint_config)

Responsible AI und Compliance

Fairness und Bias-Detection

# responsible_ai_tools.py
from azure.ai.ml import MLClient
from azure.ai.ml.entities import ResponsibleAIDashboard
import pandas as pd
import numpy as np

class ResponsibleAITools:
    def __init__(self, ml_client):
        self.ml_client = ml_client

    def create_fairness_dashboard(self, model_name, dataset_path, sensitive_features):
        """Fairness Dashboard erstellen"""
        # Daten laden
        data = pd.read_csv(dataset_path)

        # Responsible AI Dashboard konfigurieren
        dashboard_config = ResponsibleAIDashboard(
            name=f"{model_name}_fairness_dashboard",
            model_name=model_name,
            dataset_name="fairness_dataset",
            features=sensitive_features,
            target_column="target",
            task_type="classification",
            categorical_features=sensitive_features
        )

        # Dashboard erstellen
        dashboard = self.ml_client.responsible_ai.begin_create_or_update(
            dashboard_config
        ).result()

        return dashboard

    def analyze_model_fairness(self, model_predictions, sensitive_features, target):
        """Modell-Fairness analysieren"""
        fairness_metrics = {}

        for feature in sensitive_features:
            # Disparate Impact Ratio berechnen
            groups = target.unique()
            if len(groups) == 2:
                group_0 = target[target == groups[0]]
                group_1 = target[target == groups[1]]

                positive_rate_0 = np.mean(model_predictions[target == groups[0]])
                positive_rate_1 = np.mean(model_predictions[target == groups[1]])

                if positive_rate_1 > 0:
                    disparate_impact = positive_rate_0 / positive_rate_1
                else:
                    disparate_impact = float('inf')

                fairness_metrics[feature] = {
                    "disparate_impact_ratio": disparate_impact,
                    "positive_rate_group_0": positive_rate_0,
                    "positive_rate_group_1": positive_rate_1,
                    "is_fair": 0.8 <= disparate_impact <= 1.25
                }

        return fairness_metrics

    def create_explanation_dashboard(self, model_name, explanation_data):
        """Model Explanation Dashboard erstellen"""
        explanation_config = {
            "name": f"{model_name}_explanation_dashboard",
            "model_name": model_name,
            "explanation_type": "SHAP",
            "features": explanation_data["features"],
            "samples": explanation_data["samples"]
        }

        return self.ml_client.responsible_ai.begin_create_or_update(explanation_config).result()

    def generate_compliance_report(self, model_name, fairness_metrics, explanation_data):
        """Compliance-Report generieren"""
        report = {
            "model_name": model_name,
            "timestamp": pd.Timestamp.now().isoformat(),
            "fairness_analysis": {
                "overall_fairness_score": self.calculate_fairness_score(fairness_metrics),
                "feature_analysis": fairness_metrics,
                "recommendations": self.generate_fairness_recommendations(fairness_metrics)
            },
            "explainability": {
                "has_explanations": explanation_data is not None,
                "explanation_coverage": len(explanation_data["samples"]) if explanation_data else 0
            },
            "compliance_status": {
                "gdpr_compliant": True,
                "fairness_compliant": all(metrics["is_fair"] for metrics in fairness_metrics.values()),
                "transparency_compliant": explanation_data is not None
            }
        }

        return report

    def calculate_fairness_score(self, fairness_metrics):
        """Gesamt-Fairness-Score berechnen"""
        if not fairness_metrics:
            return 0.0

        fairness_scores = []
        for feature, metrics in fairness_metrics.items():
            if metrics["is_fair"]:
                fairness_scores.append(1.0)
            else:
                # Score basierend auf Abweichung von Fairness
                disparate_impact = metrics["disparate_impact_ratio"]
                if disparate_impact < 0.8:
                    score = disparate_impact / 0.8
                elif disparate_impact > 1.25:
                    score = 1.25 / disparate_impact
                else:
                    score = 1.0
                fairness_scores.append(score)

        return np.mean(fairness_scores)

    def generate_fairness_recommendations(self, fairness_metrics):
        """Fairness-Empfehlungen generieren"""
        recommendations = []

        for feature, metrics in fairness_metrics.items():
            if not metrics["is_fair"]:
                recommendations.append({
                    "feature": feature,
                    "issue": f"Disparate Impact Ratio: {metrics['disparate_impact_ratio']:.3f}",
                    "recommendation": f"Modell für Feature '{feature}' neu trainieren oder Feature-Engineering anpassen"
                })

        return recommendations

MLOps und Model Lifecycle Management

End-to-End ML Pipeline

# mlops_pipeline.py
from azure.ai.ml import MLClient, Input, Output
from azure.ai.ml.entities import Pipeline, PipelineJob
from azure.ai.ml.dsl import pipeline
from azure.ai.ml.entities import Environment, Model
import os

class MLOpsPipeline:
    def __init__(self, ml_client):
        self.ml_client = ml_client

    @pipeline
    def create_training_pipeline(self, training_data, validation_data):
        """ML-Training Pipeline erstellen"""

        # Daten-Vorverarbeitung
        @pipeline
        def preprocess_data(data_input):
            preprocess_step = self.ml_client.components.create_or_update(
                name="data_preprocessing",
                version="1.0.0",
                code="./src/preprocessing",
                environment="azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest"
            )

            return preprocess_step(
                input_data=data_input,
                output_data=Output(type="uri_folder")
            )

        # Modell-Training
        @pipeline
        def train_model(preprocessed_data):
            train_step = self.ml_client.components.create_or_update(
                name="model_training",
                version="1.0.0",
                code="./src/training",
                environment="azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest"
            )

            return train_step(
                training_data=preprocessed_data,
                model_output=Output(type="mlflow_model")
            )

        # Modell-Evaluation
        @pipeline
        def evaluate_model(trained_model, validation_data):
            eval_step = self.ml_client.components.create_or_update(
                name="model_evaluation",
                version="1.0.0",
                code="./src/evaluation",
                environment="azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest"
            )

            return eval_step(
                model=trained_model,
                validation_data=validation_data,
                evaluation_output=Output(type="uri_file")
            )

        # Pipeline zusammenstellen
        preprocessed_data = preprocess_data(training_data)
        trained_model = train_model(preprocessed_data)
        evaluation_results = evaluate_model(trained_model, validation_data)

        return {
            "model": trained_model,
            "evaluation": evaluation_results
        }

    def create_deployment_pipeline(self, model_name, environment_name):
        """Deployment Pipeline erstellen"""

        # Modell-Registrierung
        model = Model(
            name=model_name,
            version="latest",
            path=f"azureml://models/{model_name}/versions/latest"
        )

        registered_model = self.ml_client.models.create_or_update(model)

        # Online-Endpoint erstellen
        endpoint_config = {
            "name": f"{model_name}-endpoint",
            "type": "online",
            "model": registered_model,
            "environment": environment_name,
            "compute": "azureml:cpu-cluster",
            "traffic_allocation": {
                "blue": 100
            }
        }

        endpoint = self.ml_client.online_endpoints.begin_create_or_update(
            endpoint_config
        ).result()

        return endpoint

    def setup_monitoring(self, endpoint_name, monitoring_config):
        """Modell-Monitoring einrichten"""
        monitoring_setup = {
            "endpoint_name": endpoint_name,
            "data_collection": {
                "enabled": True,
                "sampling_rate": 0.1
            },
            "alerts": {
                "data_drift": True,
                "prediction_drift": True,
                "model_performance": True
            },
            "metrics": [
                "accuracy",
                "latency",
                "throughput",
                "error_rate"
            ]
        }

        return self.ml_client.monitoring.begin_create_or_update(monitoring_setup).result()

    def create_retraining_trigger(self, model_name, trigger_conditions):
        """Automatischen Retraining-Trigger erstellen"""
        trigger_config = {
            "name": f"{model_name}_retraining_trigger",
            "model_name": model_name,
            "trigger_type": "schedule",
            "schedule": "0 0 * * 0",  # Wöchentlich
            "conditions": trigger_conditions,
            "pipeline_name": f"{model_name}_training_pipeline"
        }

        return self.ml_client.triggers.begin_create_or_update(trigger_config).result()

Model Registry und Versioning

# model_registry.py
from azure.ai.ml.entities import Model, Environment
from azure.ai.ml.constants import AssetTypes
import mlflow

class ModelRegistry:
    def __init__(self, ml_client):
        self.ml_client = ml_client
        self.registry_name = "enterprise_model_registry"

    def register_model(self, model_path, model_name, version, description=""):
        """Modell im Registry registrieren"""
        model = Model(
            name=model_name,
            version=version,
            description=description,
            path=model_path,
            type=AssetTypes.MLFLOW_MODEL
        )

        registered_model = self.ml_client.models.create_or_update(model)

        # Metadaten hinzufügen
        metadata = {
            "registered_by": "mlops_pipeline",
            "training_date": mlflow.get_run(mlflow.active_run().info.run_id).data.tags.get("training_date"),
            "model_performance": self.get_model_performance(model_name, version),
            "dependencies": self.get_model_dependencies(model_path)
        }

        return registered_model, metadata

    def create_model_version(self, model_name, new_version, source_run_id):
        """Neue Modell-Version erstellen"""
        # Modell aus MLflow Run laden
        model_uri = f"runs:/{source_run_id}/model"

        model = Model(
            name=model_name,
            version=new_version,
            path=model_uri,
            type=AssetTypes.MLFLOW_MODEL
        )

        return self.ml_client.models.create_or_update(model)

    def promote_model_to_production(self, model_name, version):
        """Modell für Production freigeben"""
        # Modell-Tags aktualisieren
        model = self.ml_client.models.get(name=model_name, version=version)
        model.tags["stage"] = "production"
        model.tags["promoted_date"] = pd.Timestamp.now().isoformat()

        return self.ml_client.models.create_or_update(model)

    def get_model_lineage(self, model_name):
        """Modell-Lineage abrufen"""
        models = self.ml_client.models.list(name=model_name)

        lineage = []
        for model in models:
            lineage.append({
                "version": model.version,
                "created_date": model.created_time,
                "stage": model.tags.get("stage", "development"),
                "performance": model.tags.get("performance_metrics", {}),
                "dependencies": model.tags.get("dependencies", [])
            })

        return sorted(lineage, key=lambda x: x["version"])

    def create_model_comparison_report(self, model_name, versions):
        """Modell-Vergleichsbericht erstellen"""
        comparison_data = []

        for version in versions:
            model = self.ml_client.models.get(name=model_name, version=version)
            performance = model.tags.get("performance_metrics", {})

            comparison_data.append({
                "version": version,
                "accuracy": performance.get("accuracy", 0),
                "precision": performance.get("precision", 0),
                "recall": performance.get("recall", 0),
                "f1_score": performance.get("f1_score", 0),
                "training_date": model.created_time,
                "stage": model.tags.get("stage", "development")
            })

        return comparison_data

Integration und Deployment

Azure Kubernetes Service Integration

# aks_deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: microsoft-ai-studio-endpoint
  namespace: ai-production
spec:
  replicas: 3
  selector:
    matchLabels:
      app: ai-endpoint
  template:
    metadata:
      labels:
        app: ai-endpoint
    spec:
      containers:
        - name: ai-model
          image: mcr.microsoft.com/azureml/microsoft-ai-studio:latest
          ports:
            - containerPort: 8080
          env:
            - name: AZURE_AI_STUDIO_WORKSPACE
              value: 'your-workspace-name'
            - name: AZURE_AI_STUDIO_ENDPOINT
              value: 'your-endpoint-name'
            - name: AZURE_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: azure-credentials
                  key: client-id
            - name: AZURE_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: azure-credentials
                  key: client-secret
            - name: AZURE_TENANT_ID
              valueFrom:
                secretKeyRef:
                  name: azure-credentials
                  key: tenant-id
          resources:
            requests:
              memory: '2Gi'
              cpu: '1000m'
            limits:
              memory: '4Gi'
              cpu: '2000m'
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: ai-endpoint-service
  namespace: ai-production
spec:
  selector:
    app: ai-endpoint
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  type: LoadBalancer
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ai-endpoint-ingress
  namespace: ai-production
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
    - hosts:
        - ai.yourdomain.com
      secretName: ai-endpoint-tls
  rules:
    - host: ai.yourdomain.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: ai-endpoint-service
                port:
                  number: 80

CI/CD Pipeline mit GitHub Actions

# .github/workflows/microsoft-ai-studio-cicd.yml
name: Microsoft AI Studio CI/CD

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]

env:
  AZURE_WORKSPACE: ${{ secrets.AZURE_WORKSPACE }}
  AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
  AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.9'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install pytest pytest-cov

      - name: Run tests
        run: |
          pytest tests/ --cov=src/ --cov-report=xml

      - name: Upload coverage
        uses: codecov/codecov-action@v3
        with:
          file: ./coverage.xml

  build-and-deploy:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'

    steps:
      - uses: actions/checkout@v3

      - name: Azure login
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.9'

      - name: Install Azure CLI
        run: |
          curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

      - name: Install Azure ML CLI
        run: |
          az extension add -n ml

      - name: Build and push model
        run: |
          az ml model create \
            --name "enterprise-ai-model" \
            --version "v${{ github.run_number }}" \
            --path "./models/" \
            --resource-group $AZURE_RESOURCE_GROUP \
            --workspace-name $AZURE_WORKSPACE

      - name: Deploy to Microsoft AI Studio
        run: |
          az ml online-endpoint create \
            --name "ai-endpoint-${{ github.run_number }}" \
            --model "enterprise-ai-model:v${{ github.run_number }}" \
            --resource-group $AZURE_RESOURCE_GROUP \
            --workspace-name $AZURE_WORKSPACE \
            --environment "azureml:AzureML-ubuntu20.04-py38-cpu-inference:latest"

      - name: Update traffic
        run: |
          az ml online-endpoint update \
            --name "ai-endpoint-${{ github.run_number }}" \
            --traffic "blue=100" \
            --resource-group $AZURE_RESOURCE_GROUP \
            --workspace-name $AZURE_WORKSPACE

  security-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Run security scan
        uses: github/codeql-action/init@v2
        with:
          languages: python

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v2

Monitoring und Observability

Azure Monitor Integration

# monitoring_setup.py
from azure.monitor import MonitorClient
from azure.mgmt.monitor import MonitorManagementClient
from azure.mgmt.monitor.models import MetricAlertRuleResource
import logging

class AzureAIMonitoring:
    def __init__(self, credential, subscription_id, resource_group):
        self.monitor_client = MonitorManagementClient(credential, subscription_id)
        self.resource_group = resource_group

    def setup_model_monitoring(self, workspace_name, endpoint_name):
        """Modell-Monitoring einrichten"""

        # Metriken definieren
        metrics = [
            {
                "name": "RequestLatency",
                "description": "API Request Latency",
                "threshold": 1000,  # ms
                "operator": "GreaterThan"
            },
            {
                "name": "RequestCount",
                "description": "Number of API Requests",
                "threshold": 1000,  # requests per minute
                "operator": "GreaterThan"
            },
            {
                "name": "ErrorRate",
                "description": "Error Rate Percentage",
                "threshold": 5,  # percentage
                "operator": "GreaterThan"
            }
        ]

        # Alerts erstellen
        for metric in metrics:
            alert_rule = MetricAlertRuleResource(
                location="global",
                description=f"Alert for {metric['name']}",
                severity=3,  # Medium severity
                enabled=True,
                scopes=[f"/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}/onlineEndpoints/{endpoint_name}"],
                evaluation_frequency="PT1M",  # Every minute
                window_size="PT5M",  # 5 minute window
                criteria={
                    "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
                    "allOf": [
                        {
                            "name": f"{metric['name']}Alert",
                            "metric_name": metric["name"],
                            "operator": metric["operator"],
                            "threshold": metric["threshold"],
                            "time_aggregation": "Average"
                        }
                    ]
                }
            )

            self.monitor_client.metric_alerts.create_or_update(
                resource_group_name=self.resource_group,
                rule_name=f"{endpoint_name}-{metric['name']}-alert",
                parameters=alert_rule
            )

    def create_dashboard(self, workspace_name, endpoint_name):
        """Monitoring Dashboard erstellen"""
        dashboard_config = {
            "lenses": [
                {
                    "order": 0,
                    "parts": [
                        {
                            "position": {
                                "x": 0,
                                "y": 0,
                                "col_span": 6,
                                "row_span": 4
                            },
                            "metadata": {
                                "inputs": [],
                                "type": "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart",
                                "settings": {
                                    "content": {
                                        "chartId": "request-latency-chart",
                                        "chartType": "Line",
                                        "metrics": [
                                            {
                                                "resourceMetadata": {
                                                    "id": f"/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}/onlineEndpoints/{endpoint_name}"
                                                },
                                                "name": "RequestLatency",
                                                "aggregationType": "Average",
                                                "namespace": "Microsoft.MachineLearningServices/onlineEndpoints"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    ]
                }
            ]
        }

        return self.monitor_client.dashboards.create_or_update(
            resource_group_name=self.resource_group,
            dashboard_name=f"{endpoint_name}-dashboard",
            parameters=dashboard_config
        )

Fazit: Enterprise-KI-Revolution

Die Microsoft-Plattform revolutioniert Enterprise-KI-Entwicklung durch:

Technologische Vorteile:

  • Unified Platform für alle KI-Workloads
  • Responsible AI Tools für Compliance und Fairness
  • MLOps Integration für professionelle Deployment-Pipelines
  • Azure OpenAI Integration für State-of-the-Art LLMs

Geschäftliche Vorteile:

  • +60% schnellere KI-Entwicklung
  • +40% Kosteneinsparungen durch optimierte Ressourcennutzung
  • 100% Compliance mit Enterprise-Sicherheitsstandards
  • Nahtlose Integration in bestehende Azure-Umgebungen

Nächste Schritte:

  1. Microsoft AI Studio Workspace einrichten
  2. Prompt Flow für LLM-Entwicklung konfigurieren
  3. Responsible AI Dashboard für Compliance erstellen
  4. MLOps Pipeline für automatisiertes Deployment aufbauen

Die Plattform macht Enterprise-KI zugänglich, skalierbar und compliance-konform - die ideale Lösung für moderne Unternehmen.


Weitere Artikel zum Thema: Kubernetes AI Machine Learning, Azure Cloud, Enterprise AI

📖 Verwandte Artikel

Weitere interessante Beiträge zu ähnlichen Themen