Below is the practical active-passive APIM circuit breaker pattern for two Microsoft Foundry model endpoints, for example:
- Primary: Sweden Central
- Backup: East US 2
- APIM: front door / AI Gateway
The recommended APIM shape is:
| apiVersion: networking.k8s.io/v1 | |
| kind: Ingress | |
| metadata: | |
| name: split-traffic-ingress | |
| annotations: | |
| nginx.ingress.kubernetes.io/rewrite-target: / | |
| spec: | |
| ingressClassName: webapprouting.kubernetes.azure.com | |
| rules: | |
| - http: |
| # Example: | |
| # spark.master spark://master:7077 | |
| # spark.eventLog.enabled true | |
| # spark.eventLog.dir hdfs://namenode:8021/directory | |
| # spark.serializer org.apache.spark.serializer.KryoSerializer | |
| # spark.driver.memory 5g | |
| # spark.executor.extraJavaOptions -XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three" | |
| spark.driver.extraClassPath /glue/aws-glue-libs/jarsv1/* | |
| spark.executor.extraClassPath /glue/aws-glue-libs/jarsv1/* |
| import json | |
| import boto3 | |
| ec2_client = boto3.client('ec2') | |
| client = boto3.client('resourcegroupstaggingapi') | |
| def lambda_handler(event, context): | |
| # TODO implement | |
| ec2_instances = client.get_resources( | |
| TagFilters=[ |
| [Unit] | |
| Description=Example .NET Web API App running on Amazon Linux | |
| [Service] | |
| WorkingDirectory=/home/ec2-user/letsdotnet | |
| ExecStart=/usr/bin/dotnet /home/ec2-user/letsdotnet/LetsDotNet.dll | |
| Restart=always | |
| # Restart service after 10 seconds if the dotnet service crashes: | |
| RestartSec=10 |
| FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env | |
| WORKDIR /app | |
| COPY *.csproj ./ | |
| RUN dotnet restore | |
| COPY . ./ | |
| RUN dotnet publish -c Release -o output | |
| # Runtime image | |
| FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 | |
| WORKDIR /app |
| { | |
| "AWSTemplateFormatVersion" : "2010-09-09", | |
| "Description" : "", | |
| "Parameters" : { | |
| }, | |
| "Resources" : { | |
| "IISServer" : { | |
| "Type" : "AWS::EC2::Instance", | |
| "Metadata" : { | |
| "AWS::CloudFormation::Init" : { |
| { | |
| "customer-id" :"0123", | |
| "invoice-number" : "567", | |
| "line-items" : { | |
| "line-1" : "book1", | |
| "line-2" : "book2", | |
| "line-3" : "book3" | |
| } |
| #!/bin/bash | |
| sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' | |
| apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 | |
| apt-get update -y | |
| apt-get install dotnet-dev-1.0.0-preview2-003131 -y | |
| bash <(curl -fsSL https://raw.githubusercontent.com/PowerShell/PowerShell/v6.0.0-alpha.10/tools/download.sh) | |
| apt-get update | |
| apt-get install python-pip | |
| apt-get install ruby2.0 | |
| apt-get install wget |
| #!/bin/bash | |
| yum install -y aws-cli | |
| cd /home/ec2-user/ | |
| aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1 | |
| yum -y install codedeploy-agent.noarch.rpm |