빠른 시작: Azure Resource Manager로 컨테이너용 Azure Firewall 배포하기

이 퀵 시작에서는 Azure Resource Manager(ARM) 템플릿을 사용하여 새로운 AKS(Azure Kubernetes Service) 클러스터와 Azure Firewall for Containers용 Azure Firewall Premium을 생성합니다. 템플릿은 관리 아이덴티티, 방화벽 정책, 네트워크 라우팅도 구성합니다.

기본적으로 템플릿은 Azure 리소스만 배포합니다. 그런 다음 템플릿의 README의 지침에 따라 Azure Firewall 컨트롤러를 설치하고 샘플 보안 정책을 연결합니다. 선택적 매개변수를 사용하면 컨트롤러, 샘플 정책 및 테스트 포드도 설치됩니다.

Azure Resource Manager 템플릿은 프로젝트의 인프라 및 구성을 정의하는 JSON(JavaScript Object Notation) 파일입니다. 이 템플릿은 선언적 구문을 사용합니다. 배포를 만들기 위한 프로그래밍 명령의 시퀀스를 작성하지 않고 의도하는 배포를 설명합니다.

Important

Azure Firewall for Containers는 현재 공개 프리뷰 단계입니다. 베타, 미리 보기로 제공되거나 아직 일반 공급으로 릴리스되지 않은 Azure 기능에 적용되는 약관은 Microsoft Azure 미리 보기에 대한 추가 사용 약관을 참조하세요.

환경이 사전 요구 조건을 충족하면 'Azure에 배포'를 선택하세요. 템플릿은 Azure 포털의 사용자 지정 배포 페이지에서 열립니다.

ARM 템플릿을 Azure에 배포하는 버튼.

Prerequisites

  • 활성 구독이 있는 Azure 계정. 무료로 계정을 만듭니다.
  • 지원되는 미리보기 영역에서 Azure Firewall for Containers에 대한 접근.
  • 구독에 등록된 Microsoft.ContainerService 및 Microsoft.Network 리소스 공급자 및 관련 정보.
  • 리소스 그룹에서 AKS, 네트워킹 리소스, 관리 대상 ID 및 역할 할당 생성 권한. 역할 할당을 생성하려면 할당 범위에 적절한 역할(예: Role Based Access Control Administrator)이 필요합니다.
  • 선택한 AKS 노드 가상 머신 크기의 용량 및 할당량. 기본 배포는 크기가 Standard_DS3_v2있는 두 개의 노드를 사용합니다; 이 크기는 선택한 지역에서 사용 가능해야 합니다.
  • 배포 후 단계에는 Azure CLI, kubectl, Helm이 사용됩니다.

격리된 평가 환경을 사용하세요. 템플릿은 새 클러스터를 생성하고 AKS 서브넷의 아웃바운드 트래픽을 방화벽을 통해 라우팅합니다.

템플릿의 Location 매개변수를 기본값으로 유지하려면 다음 미리보기 영역 중 하나에서 리소스 그룹을 선택하거나 생성하세요:

Region Azure 지역 값
미국 중부 EUAP centraluseuap
미국 동부 2 EUAP eastus2euap
미국 중서부 westcentralus
East Asia eastasia
UK South uksouth
Central US centralus

템플릿 검토

템플릿은 Azure Quickstart Templates에서 가져온 것입니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.48.1.52935",
      "templateHash": "16522364362503515072"
    }
  },
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources. Must be an Azure Firewall for Containers preview region (centraluseuap, eastus2euap, westcentralus, eastasia, uksouth, centralus)."
      }
    },
    "namePrefix": {
      "type": "string",
      "defaultValue": "afc",
      "maxLength": 12,
      "metadata": {
        "description": "Prefix used to name the resources."
      }
    },
    "nodeVmSize": {
      "type": "string",
      "defaultValue": "Standard_DS3_v2",
      "metadata": {
        "description": "VM size for the AKS nodes. Must be available in the selected region."
      }
    },
    "nodeCount": {
      "type": "int",
      "defaultValue": 2,
      "minValue": 1,
      "maxValue": 10,
      "metadata": {
        "description": "Number of AKS nodes."
      }
    },
    "controllerVersion": {
      "type": "string",
      "defaultValue": "20261109.1",
      "metadata": {
        "description": "Azure Firewall for Containers controller Helm chart version."
      }
    },
    "controllerNamespace": {
      "type": "string",
      "defaultValue": "firewall-namespace",
      "metadata": {
        "description": "Kubernetes namespace for the controller. Used in the workload identity federated credential subject."
      }
    },
    "deployControllerAndSample": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "false (default): deploy Azure resources only; the outputs contain the remaining commands. true: also run a deployment script that installs the controller and applies a sample security policy, attachment, and test pods. The script needs a storage account with shared key access, so it fails where Azure Policy denies shared key access."
      }
    },
    "azCliVersion": {
      "type": "string",
      "defaultValue": "2.61.0",
      "metadata": {
        "description": "Azure CLI version used by the deployment script."
      }
    },
    "utcValue": {
      "type": "string",
      "defaultValue": "[utcNow()]",
      "metadata": {
        "description": "Unique suffix that forces the deployment script to rerun on each deployment. Leave the default."
      }
    }
  },
  "variables": {
    "$fxv#0": "#!/bin/bash\n# Runs inside Microsoft.Resources/deploymentScripts (Azure CLI container, signed in with the script identity).\n# Installs the Azure Firewall for Containers controller and applies a sample policy, attachment, and test pods.\nset -euo pipefail\n\necho \"Getting cluster credentials for ${CLUSTER_NAME}\"\naz aks get-credentials --resource-group \"$RESOURCE_GROUP\" --name \"$CLUSTER_NAME\" --admin --file ./kubeconfig --overwrite-existing --only-show-errors\nchmod 600 ./kubeconfig\nexport KUBECONFIG=\"$PWD/kubeconfig\"\n\ndownload() { # url dest; the Azure CLI container image may not include curl\n  if command -v curl >/dev/null 2>&1; then curl -fsSL \"$1\" -o \"$2\"\n  elif command -v wget >/dev/null 2>&1; then wget -qO \"$2\" \"$1\"\n  else python3 -c \"import sys, urllib.request; urllib.request.urlretrieve(sys.argv[1], sys.argv[2])\" \"$1\" \"$2\"\n  fi\n}\n\necho \"Installing kubectl and helm\"\naz aks install-cli --install-location /usr/local/bin/kubectl --kubelogin-install-location /usr/local/bin/kubelogin --only-show-errors >/dev/null\ndownload https://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz /tmp/helm.tar.gz\ntar -xzf /tmp/helm.tar.gz -C /tmp\ninstall /tmp/linux-amd64/helm /usr/local/bin/helm\n\necho \"Installing controller ${CONTROLLER_VERSION}\"\nhelm upgrade --install azfw-controller \\\n  oci://mcr.microsoft.com/firewall/charts/azurefirewall-controller \\\n  --namespace \"$CONTROLLER_NAMESPACE\" \\\n  --create-namespace \\\n  --version \"$CONTROLLER_VERSION\" \\\n  --set \"azfwController.podIdentity.clientID=${CONTROLLER_CLIENT_ID}\" \\\n  --wait --timeout 10m\nkubectl wait --for=condition=Available deploy --all --namespace \"$CONTROLLER_NAMESPACE\" --timeout=10m\nkubectl wait --for=condition=Established crd/securitypolicyattachments.firewall.networking.azure.io --timeout=5m\n\necho \"Applying sample security policy and attachment\"\nkubectl apply -f - <<EOF\napiVersion: firewall.networking.azure.io/v1alpha1\nkind: SecurityPolicy\nmetadata:\n  name: example-securitypolicy-rules\n  namespace: default\nspec:\n  applicationRuleCollections:\n    - name: test-application-rules\n      refs:\n        - podSelector:\n            matchLabels:\n              role: developer\n      action: Allow\n      egress:\n        - name: allow-test-destinations\n          toPortProtocol:\n            - protocolType: HTTPS\n              port: 443\n          to:\n            - fqdn:\n                - \"*.microsoft.com\"\n                - \"*.google.com\"\n---\napiVersion: firewall.networking.azure.io/v1alpha1\nkind: SecurityPolicyAttachment\nmetadata:\n  name: example-attachment\n  namespace: default\nspec:\n  securityPolicyRefs:\n    - name: example-securitypolicy-rules\n      namespace: default\n  firewallRef:\n    id: ${FIREWALL_ID}\n  aksWorkloadSubnets:\n    - ${AKS_SUBNET_ID}\nEOF\n\necho \"Waiting for the attachment to deploy\"\nkubectl wait --for=jsonpath='{.status.conditions[?(@.type==\"Deployment\")].reason}'=Ready \\\n  securitypolicyattachment/example-attachment --namespace default --timeout=40m\nkubectl get securitypolicyattachment example-attachment --namespace default \\\n  -o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}{\"\\n\"}{end}'\n\necho \"Creating test pods\"\nkubectl apply -f - <<'EOF'\napiVersion: v1\nkind: Pod\nmetadata:\n  name: developer-pod\n  namespace: default\n  labels:\n    role: developer\nspec:\n  containers:\n    - name: developer\n      image: mcr.microsoft.com/azure-cli:latest\n      command: [\"sleep\", \"infinity\"]\n---\napiVersion: v1\nkind: Pod\nmetadata:\n  name: other-pod\n  namespace: default\n  labels:\n    role: other\nspec:\n  containers:\n    - name: other\n      image: mcr.microsoft.com/azure-cli:latest\n      command: [\"sleep\", \"infinity\"]\nEOF\nkubectl wait --for=condition=Ready pod/developer-pod pod/other-pod --namespace default --timeout=10m\n\nATTACH_STATUS=$(kubectl get securitypolicyattachment example-attachment --namespace default \\\n  -o jsonpath='{.status.conditions[?(@.type==\"Deployment\")].reason}')\ncat > \"$AZ_SCRIPTS_OUTPUT_PATH\" <<EOF\n{\"controllerVersion\": \"${CONTROLLER_VERSION}\", \"attachmentDeployment\": \"${ATTACH_STATUS}\"}\nEOF\necho \"Done\"\n",
    "vnetName": "[format('{0}-vnet', parameters('namePrefix'))]",
    "aksSubnetName": "aks-subnet",
    "vnetAddressPrefix": "10.224.0.0/12",
    "aksSubnetPrefix": "10.224.0.0/16",
    "firewallSubnetPrefix": "10.225.0.0/26",
    "firewallMgmtSubnetPrefix": "10.225.1.0/26",
    "clusterName": "[format('{0}-aks', parameters('namePrefix'))]",
    "firewallName": "[format('{0}-firewall', parameters('namePrefix'))]",
    "firewallPolicyName": "[format('{0}-firewall-policy', parameters('namePrefix'))]",
    "routeTableName": "[format('{0}-aks-rt', parameters('namePrefix'))]",
    "controllerServiceAccount": "azurefirewall-controller-sa",
    "networkContributorRoleId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')]",
    "aksClusterAdminRoleId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0ab0b1a8-8aac-4efd-b8c2-3ee1fb270be8')]",
    "aksSubnetId": "[format('{0}/subnets/{1}', resourceId('Microsoft.Network/virtualNetworks', variables('vnetName')), variables('aksSubnetName'))]"
  },
  "resources": [
    {
      "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
      "apiVersion": "2024-11-30",
      "name": "[format('{0}-aks-identity', parameters('namePrefix'))]",
      "location": "[parameters('location')]"
    },
    {
      "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
      "apiVersion": "2024-11-30",
      "name": "[format('{0}-controller-identity', parameters('namePrefix'))]",
      "location": "[parameters('location')]"
    },
    {
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2025-05-01",
      "name": "[variables('vnetName')]",
      "location": "[parameters('location')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[variables('vnetAddressPrefix')]"
          ]
        },
        "subnets": [
          {
            "name": "[variables('aksSubnetName')]",
            "properties": {
              "addressPrefix": "[variables('aksSubnetPrefix')]",
              "defaultOutboundAccess": false
            }
          },
          {
            "name": "AzureFirewallSubnet",
            "properties": {
              "addressPrefix": "[variables('firewallSubnetPrefix')]",
              "defaultOutboundAccess": false
            }
          },
          {
            "name": "AzureFirewallManagementSubnet",
            "properties": {
              "addressPrefix": "[variables('firewallMgmtSubnetPrefix')]",
              "defaultOutboundAccess": false
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Authorization/roleAssignments",
      "apiVersion": "2022-04-01",
      "scope": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
      "name": "[guid(resourceId('Microsoft.Network/virtualNetworks', variables('vnetName')), resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-aks-identity', parameters('namePrefix'))), variables('networkContributorRoleId'))]",
      "properties": {
        "roleDefinitionId": "[variables('networkContributorRoleId')]",
        "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-aks-identity', parameters('namePrefix'))), '2024-11-30').principalId]",
        "principalType": "ServicePrincipal"
      },
      "dependsOn": [
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-aks-identity', parameters('namePrefix')))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2025-05-01",
      "name": "[format('{0}-fw-ip', parameters('namePrefix'))]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "publicIPAllocationMethod": "Static",
        "publicIPAddressVersion": "IPv4"
      }
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2025-05-01",
      "name": "[format('{0}-fw-mgmt-ip', parameters('namePrefix'))]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "publicIPAllocationMethod": "Static",
        "publicIPAddressVersion": "IPv4"
      }
    },
    {
      "type": "Microsoft.Network/firewallPolicies",
      "apiVersion": "2025-05-01",
      "name": "[variables('firewallPolicyName')]",
      "location": "[parameters('location')]",
      "properties": {
        "sku": {
          "tier": "Premium"
        },
        "threatIntelMode": "Alert"
      }
    },
    {
      "type": "Microsoft.Network/firewallPolicies/ruleCollectionGroups",
      "apiVersion": "2025-05-01",
      "name": "[format('{0}/{1}', variables('firewallPolicyName'), 'default-allow-aks-controlplane')]",
      "properties": {
        "priority": 100,
        "ruleCollections": [
          {
            "ruleCollectionType": "FirewallPolicyFilterRuleCollection",
            "name": "AllowAksControlPlaneNetwork",
            "priority": 100,
            "action": {
              "type": "Allow"
            },
            "rules": [
              {
                "ruleType": "NetworkRule",
                "name": "Allow_AKS_ControlPlane_Network",
                "ipProtocols": [
                  "TCP"
                ],
                "sourceAddresses": [
                  "*"
                ],
                "destinationAddresses": [
                  "AzureKubernetesService"
                ],
                "destinationPorts": [
                  "443"
                ]
              }
            ]
          },
          {
            "ruleCollectionType": "FirewallPolicyFilterRuleCollection",
            "name": "AllowAksControlPlaneApp",
            "priority": 101,
            "action": {
              "type": "Allow"
            },
            "rules": [
              {
                "ruleType": "ApplicationRule",
                "name": "Allow_AKS_ControlPlane_App",
                "sourceAddresses": [
                  "*"
                ],
                "fqdnTags": [
                  "AzureKubernetesService"
                ],
                "protocols": [
                  {
                    "protocolType": "Https",
                    "port": 443
                  }
                ]
              },
              {
                "ruleType": "ApplicationRule",
                "name": "Allow_AFC_Service",
                "sourceAddresses": [
                  "*"
                ],
                "targetFqdns": [
                  "*.afc.azure.com"
                ],
                "protocols": [
                  {
                    "protocolType": "Https",
                    "port": 443
                  }
                ]
              }
            ]
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/firewallPolicies', variables('firewallPolicyName'))]"
      ]
    },
    {
      "type": "Microsoft.Network/azureFirewalls",
      "apiVersion": "2025-05-01",
      "name": "[variables('firewallName')]",
      "location": "[parameters('location')]",
      "properties": {
        "sku": {
          "name": "AZFW_VNet",
          "tier": "Premium"
        },
        "firewallPolicy": {
          "id": "[resourceId('Microsoft.Network/firewallPolicies', variables('firewallPolicyName'))]"
        },
        "ipConfigurations": [
          {
            "name": "data-ipconfig",
            "properties": {
              "subnet": {
                "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), 'AzureFirewallSubnet')]"
              },
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-fw-ip', parameters('namePrefix')))]"
              }
            }
          }
        ],
        "managementIpConfiguration": {
          "name": "mgmt-ipconfig",
          "properties": {
            "subnet": {
              "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), 'AzureFirewallManagementSubnet')]"
            },
            "publicIPAddress": {
              "id": "[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-fw-mgmt-ip', parameters('namePrefix')))]"
            }
          }
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/firewallPolicies/ruleCollectionGroups', variables('firewallPolicyName'), 'default-allow-aks-controlplane')]",
        "[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-fw-mgmt-ip', parameters('namePrefix')))]",
        "[resourceId('Microsoft.Network/firewallPolicies', variables('firewallPolicyName'))]",
        "[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-fw-ip', parameters('namePrefix')))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
      ]
    },
    {
      "type": "Microsoft.ContainerService/managedClusters",
      "apiVersion": "2025-07-01",
      "name": "[variables('clusterName')]",
      "location": "[parameters('location')]",
      "identity": {
        "type": "UserAssigned",
        "userAssignedIdentities": {
          "[format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-aks-identity', parameters('namePrefix'))))]": {}
        }
      },
      "properties": {
        "dnsPrefix": "[variables('clusterName')]",
        "agentPoolProfiles": [
          {
            "name": "nodepool1",
            "mode": "System",
            "count": "[parameters('nodeCount')]",
            "vmSize": "[parameters('nodeVmSize')]",
            "osType": "Linux",
            "type": "VirtualMachineScaleSets",
            "vnetSubnetID": "[variables('aksSubnetId')]"
          }
        ],
        "networkProfile": {
          "networkPlugin": "azure",
          "outboundType": "loadBalancer",
          "loadBalancerSku": "standard",
          "serviceCidr": "10.240.0.0/16",
          "dnsServiceIP": "10.240.0.10"
        },
        "oidcIssuerProfile": {
          "enabled": true
        },
        "securityProfile": {
          "workloadIdentity": {
            "enabled": true
          }
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-aks-identity', parameters('namePrefix')))]",
        "[extensionResourceId(resourceId('Microsoft.Network/virtualNetworks', variables('vnetName')), 'Microsoft.Authorization/roleAssignments', guid(resourceId('Microsoft.Network/virtualNetworks', variables('vnetName')), resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-aks-identity', parameters('namePrefix'))), variables('networkContributorRoleId')))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
      ]
    },
    {
      "type": "Microsoft.Authorization/roleAssignments",
      "apiVersion": "2022-04-01",
      "name": "[guid(resourceGroup().id, resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix'))), variables('networkContributorRoleId'))]",
      "properties": {
        "roleDefinitionId": "[variables('networkContributorRoleId')]",
        "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix'))), '2024-11-30').principalId]",
        "principalType": "ServicePrincipal"
      },
      "dependsOn": [
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix')))]"
      ]
    },
    {
      "type": "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials",
      "apiVersion": "2024-11-30",
      "name": "[format('{0}/{1}', format('{0}-controller-identity', parameters('namePrefix')), 'azurefirewall-controller')]",
      "properties": {
        "issuer": "[reference(resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName')), '2025-07-01').oidcIssuerProfile.issuerURL]",
        "subject": "[format('system:serviceaccount:{0}:{1}', parameters('controllerNamespace'), variables('controllerServiceAccount'))]",
        "audiences": [
          "api://AzureADTokenExchange"
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix')))]"
      ]
    },
    {
      "type": "Microsoft.Network/routeTables",
      "apiVersion": "2025-05-01",
      "name": "[variables('routeTableName')]",
      "location": "[parameters('location')]",
      "properties": {
        "routes": [
          {
            "name": "to-firewall",
            "properties": {
              "addressPrefix": "0.0.0.0/0",
              "nextHopType": "VirtualAppliance",
              "nextHopIpAddress": "[reference(resourceId('Microsoft.Network/azureFirewalls', variables('firewallName')), '2025-05-01').ipConfigurations[0].properties.privateIPAddress]"
            }
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/azureFirewalls', variables('firewallName'))]"
      ]
    },
    {
      "type": "Microsoft.Network/virtualNetworks/subnets",
      "apiVersion": "2025-05-01",
      "name": "[format('{0}/{1}', variables('vnetName'), variables('aksSubnetName'))]",
      "properties": {
        "addressPrefix": "[variables('aksSubnetPrefix')]",
        "defaultOutboundAccess": false,
        "routeTable": {
          "id": "[resourceId('Microsoft.Network/routeTables', variables('routeTableName'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]",
        "[resourceId('Microsoft.Network/routeTables', variables('routeTableName'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
      ]
    },
    {
      "condition": "[parameters('deployControllerAndSample')]",
      "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
      "apiVersion": "2024-11-30",
      "name": "[format('{0}-script-identity', parameters('namePrefix'))]",
      "location": "[parameters('location')]"
    },
    {
      "condition": "[parameters('deployControllerAndSample')]",
      "type": "Microsoft.Authorization/roleAssignments",
      "apiVersion": "2022-04-01",
      "scope": "[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]",
      "name": "[guid(resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName')), format('{0}-script-identity', parameters('namePrefix')), variables('aksClusterAdminRoleId'))]",
      "properties": {
        "roleDefinitionId": "[variables('aksClusterAdminRoleId')]",
        "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-script-identity', parameters('namePrefix'))), '2024-11-30').principalId]",
        "principalType": "ServicePrincipal"
      },
      "dependsOn": [
        "[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-script-identity', parameters('namePrefix')))]"
      ]
    },
    {
      "condition": "[parameters('deployControllerAndSample')]",
      "type": "Microsoft.Resources/deploymentScripts",
      "apiVersion": "2023-08-01",
      "name": "[format('{0}-install-controller', parameters('namePrefix'))]",
      "location": "[parameters('location')]",
      "kind": "AzureCLI",
      "identity": {
        "type": "UserAssigned",
        "userAssignedIdentities": {
          "[format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-script-identity', parameters('namePrefix'))))]": {}
        }
      },
      "properties": {
        "azCliVersion": "[parameters('azCliVersion')]",
        "timeout": "PT1H",
        "retentionInterval": "P1D",
        "cleanupPreference": "OnSuccess",
        "forceUpdateTag": "[parameters('utcValue')]",
        "environmentVariables": [
          {
            "name": "RESOURCE_GROUP",
            "value": "[resourceGroup().name]"
          },
          {
            "name": "CLUSTER_NAME",
            "value": "[variables('clusterName')]"
          },
          {
            "name": "CONTROLLER_VERSION",
            "value": "[parameters('controllerVersion')]"
          },
          {
            "name": "CONTROLLER_NAMESPACE",
            "value": "[parameters('controllerNamespace')]"
          },
          {
            "name": "CONTROLLER_CLIENT_ID",
            "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix'))), '2024-11-30').clientId]"
          },
          {
            "name": "FIREWALL_ID",
            "value": "[resourceId('Microsoft.Network/azureFirewalls', variables('firewallName'))]"
          },
          {
            "name": "AKS_SUBNET_ID",
            "value": "[variables('aksSubnetId')]"
          }
        ],
        "scriptContent": "[variables('$fxv#0')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), variables('aksSubnetName'))]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials', format('{0}-controller-identity', parameters('namePrefix')), 'azurefirewall-controller')]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix')))]",
        "[resourceId('Microsoft.Authorization/roleAssignments', guid(resourceGroup().id, resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix'))), variables('networkContributorRoleId')))]",
        "[resourceId('Microsoft.Network/azureFirewalls', variables('firewallName'))]",
        "[extensionResourceId(resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName')), 'Microsoft.Authorization/roleAssignments', guid(resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName')), format('{0}-script-identity', parameters('namePrefix')), variables('aksClusterAdminRoleId')))]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-script-identity', parameters('namePrefix')))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
      ]
    }
  ],
  "outputs": {
    "clusterName": {
      "type": "string",
      "value": "[variables('clusterName')]"
    },
    "firewallId": {
      "type": "string",
      "value": "[resourceId('Microsoft.Network/azureFirewalls', variables('firewallName'))]"
    },
    "firewallPrivateIp": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.Network/azureFirewalls', variables('firewallName')), '2025-05-01').ipConfigurations[0].properties.privateIPAddress]"
    },
    "firewallPolicyId": {
      "type": "string",
      "value": "[resourceId('Microsoft.Network/firewallPolicies', variables('firewallPolicyName'))]"
    },
    "aksSubnetId": {
      "type": "string",
      "value": "[variables('aksSubnetId')]"
    },
    "controllerIdentityClientId": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix'))), '2024-11-30').clientId]"
    },
    "getCredentialsCommand": {
      "type": "string",
      "value": "[format('az aks get-credentials --resource-group {0} --name {1}', resourceGroup().name, variables('clusterName'))]"
    },
    "helmInstallCommand": {
      "type": "string",
      "value": "[format('helm install azfw-controller oci://mcr.microsoft.com/firewall/charts/azurefirewall-controller --namespace {0} --create-namespace --version {1} --set azfwController.podIdentity.clientID={2}', parameters('controllerNamespace'), parameters('controllerVersion'), reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-controller-identity', parameters('namePrefix'))), '2024-11-30').clientId)]"
    },
    "attachmentFirewallRef": {
      "type": "string",
      "value": "[format('firewallRef: {{ id: {0} }}', resourceId('Microsoft.Network/azureFirewalls', variables('firewallName')))]"
    },
    "controllerAndSampleInstalled": {
      "type": "bool",
      "value": "[parameters('deployControllerAndSample')]"
    }
  }
}

템플릿은 다음 리소스를 생성합니다:

Resource Purpose
가상 네트워크 및 서브넷 AKS 서브넷, AzureFirewallSubnet 및 다음 제공: AzureFirewallManagementSubnet
AKS 클러스터 Azure CNI, OIDC 발급자 및 워크로드 ID를 사용하여 워크로드를 실행하세요.
Azure Firewall 프리미엄 및 공용 IP 주소 클러스터의 아웃바운드 트래픽을 점검하세요
방화벽 정책 및 규칙 컬렉션 그룹 필요한 AKS 아웃바운드 트래픽과 HTTPS를 허용합니다. *.afc.azure.com
경로 테이블 및 서브넷 연관 AKS 서브넷의 아웃바운드 트래픽을 방화벽을 통해 라우팅하세요
관리형 ID, 역할 할당 및 연합 ID 자격 증명 AKS 네트워킹 및 Azure Firewall Controller 권한 부여
선택적 배포 스크립트 및 해당 스크립트의 식별자 Deploy Controller And Sample이 true일 때 컨트롤러, 샘플 정책, 첨부 파일 및 테스트 팟을 설치하세요.

템플릿 배포

환경에서 선택적 배포 스크립트를 허용하지 않는 한, 컨트롤러 및 샘플 배포 설정을 false로 유지하세요.

  1. 소개 끝에서 'Azure로 배포'를 선택하고 Azure에 로그인하세요. 포털이 사용자 지정 배포 페이지를 엽니다.

  2. 다음 설정을 구성합니다.

    설정 값
    구독 평가를 위한 구독을 선택하세요
    리소스 그룹 리소스 그룹을 선택하거나 생성하세요; 새롭고 전용 리소스 그룹이 정리를 더 안전하게 만듭니다
    지역 사전 요구 사항에 나열된 미리보기 리전을 사용하세요
    이름 접두사 기본 afc을(를) 사용하거나 리소스 이름에 접두사 입력
    노드 VM 크기 선택한 지역에서 사용 가능한 경우에만 사용 Standard_DS3_v2 하세요. 그렇지 않으면 사용 가능한 크기를 입력하세요
    컨트롤러 및 샘플 배포 false를 그대로 두면 Azure 리소스만 배포하고, README의 설치 단계를 따르세요. 배포 스크립트에 공유 키 접근이 허용된 경우에만 true 로 설정합니다

    Note

    컨트롤러 및 샘플 배포 설정이 true(으)로 되어 있으면 템플릿은 공유 키 액세스 권한이 있는 스토리지 계정이 필요한 배포 스크립트를 실행합니다. Azure Policy Storage 기본 제공 계정에서 공유 키 액세스를 차단하도록 설정되어 있고 해당 계정이 거부로 지정된 경우 배포가 실패합니다. 기본값(false)을 유지하고 설치 단계를 따르거나, 템플릿 README 를 확인하여 정책을 확인하고 면제를 요청하세요.

  3. 다른 매개변수들은 기본값 그대로 두세요. 검토 + 생성을 선택하고 검증 결과를 검토하세요.

  4. Create를 선택합니다.

Azure 리소스 배포에는 약 10~15분이 소요되며, 컨트롤러 및 샘플 배포 옵션을 true로 설정한 경우에는 30~45분이 소요됩니다. 배포 시간은 다를 수 있습니다.

배포된 리소스 검토

  1. Azure 포털에서 리소스 그룹을 열고 배포를 선택합니다. 템플릿 배포를 열고 성공적으로 실행되었는지 확인하십시오.

  2. 배포된 AKS 클러스터, Azure Firewall, 방화벽 정책, 가상 네트워크, 라우팅 및 식별자를 검토합니다. 클러스터 이름, 방화벽 리소스 ID 및 다음 단계를 위한 명령을 찾으려면 출력을 선택하십시오.

  3. 배포 옵션에 대한 컨트롤러 및 정책 설정을 완료하세요:

    배포 옵션 다음 작업
    Deploy Controller And Sample이 false입니다. ' 컨트롤러 설치 및 정책 첨부'를 따르세요. README 파일의 예시 명령어 대신 getCredentialsCommand 및 helmInstallCommand 배포 출력 결과를 사용하세요. 샘플 방화벽 참조 및 정책 첨부 파일을 생성할 때 출력에 있는 리소스 ID 사용
    컨트롤러 및 샘플 배포가true임 배포 스크립트는 컨트롤러, 샘플 정책, 첨부 파일 및 테스트 파드를 설치합니다. 자신의 환경에서 연결하려면 실행 getCredentialsCommand 하세요. 기존 리소스를 다시 생성하지 않도록 README의 컨트롤러 설치 및 포드 생성 명령을 건너뛰세요

Azure CLI 명령을 실행하기 전에 로그인하여 이 배포에 사용되는 구독을 선택하세요. 이름 접두사를 변경한 경우 README의 기본 리소스 이름 대신 clusterName, firewallId, aksSubnetId, controllerIdentityClientId와(과) 같은 배포 출력을 사용하세요.

README의 트래픽 테스트를 사용하여 샘플 정책의 허용 및 거부 동작을 검증하세요. 배포 스크립트가 이미 테스트 파드를 생성한 경우, 기존 파드에 대해 테스트 명령을 사용하세요. 성공적인 Azure 배포만으로는 트래픽 필터링이 검증되지는 않습니다.

자원을 정리하세요

이 빠른 시작을 위해 리소스 그룹을 생성했다면 배포 평가를 완료한 후 해당 리소스 그룹 삭제

  1. Azure 포털에서 리소스 그룹을 열고 리소스를 검토하세요. 보관해야 할 리소스가 없는지 확인하세요.
  2. 리소스 그룹 삭제를 선택합니다.
  3. 리소스 그룹 이름을 입력하고 삭제를 확인합니다.

리소스 그룹을 삭제하면 해당 그룹의 모든 리소스가 제거됩니다. 리소스 그룹을 재사용했다면 그룹을 삭제하지 마세요. 이 평가를 위해 생성한 리소스만 제거합니다. 개별 정책이나 첨부 파일을 제거해야 하는 경우 컨트롤러 정리 지침을 따르십시오.

다음 단계