Azure Managed Applications를 배포할 때 Key Vault 비밀 액세스

배포 중에 보안 값(예: 암호)을 매개 변수로 전달해야 할 경우 Azure Key Vault에서 값을 검색할 수 있습니다. Managed Applications를 배포할 때 Key Vault에 액세스하려면 어플라이언스 리소스 공급자 서비스 주체에 액세스를 허용해야 합니다. Managed Applications 서비스는 이 ID를 사용하여 작업을 실행합니다. 배포하는 동안 Key Vault에서 값을 검색하려면 서비스 주체가 Key Vault에 액세스할 수 있어야 합니다.

이 문서에서는 Managed Applications로 작업하려면 Key Vault를 구성하는 방법을 설명합니다.

템플릿 배포 사용

  1. Azure Portal에 로그인합니다.

  2. 키 자격 증명 모음을 엽니다. 검색 상자에 키 자격 증명 모음를 입력하거나 키 자격 증명 모음를 선택합니다.

    Screenshot of the Azure home page to open a key vault using search or by selecting key vault.

  3. 액세스 구성을 선택합니다.

    Screenshot of the key vault setting to select access configuration.

  4. 템플릿 배포용 Azure Resource Manager를 선택합니다. 그런 다음, 적용을 선택합니다.

    Screenshot of the key vault's access configuration that enables Azure Resource Manager for template deployment.

서비스를 기여자로 추가

키 자격 증명 모음 범위에서 어플라이언스 리소스 공급자 사용자에게 기여자 역할을 할당합니다. 기여자 역할은 역할 할당에 대한 권한 있는 관리자 역할입니다. 자세한 단계는 Azure Portal을 사용하여 Azure 역할 할당으로 이동하세요.

Appliance Resource Provider는 Microsoft Entra 테넌트의 서비스 주체입니다. Azure Portal에서 Microsoft Entra ID>엔터프라이즈 애플리케이션으로 이동하여 검색 필터를 Microsoft 애플리케이션으로 변경하여 등록되었는지 확인할 수 있습니다. 어플라이언스 리소스 공급자를 검색합니다. 찾을 수 없으면 Microsoft.Solutions 리소스 공급자를 등록합니다.

Key Vault 비밀 참조

Key Vault에서 관리형 애플리케이션의 템플릿으로 암호를 전달하려면 연결되거나 중첩된 템플릿을 사용하고 연결되거나 중첩된 템플릿의 매개 변수에서 Key Vault를 참조해야 합니다. Key Vault의 리소스 ID 및 비밀의 이름을 제공합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location where the resources will be deployed."
      }
    },
    "vaultName": {
      "type": "string",
      "metadata": {
        "description": "The name of the key vault that contains the secret."
      }
    },
    "secretName": {
      "type": "string",
      "metadata": {
        "description": "The name of the secret."
      }
    },
    "vaultResourceGroupName": {
      "type": "string",
      "metadata": {
        "description": "The name of the resource group that contains the key vault."
      }
    },
    "vaultSubscription": {
      "type": "string",
      "defaultValue": "[subscription().subscriptionId]",
      "metadata": {
        "description": "The name of the subscription that contains the key vault."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "dynamicSecret",
      "properties": {
        "mode": "Incremental",
        "expressionEvaluationOptions": {
          "scope": "inner"
        },
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
            "adminLogin": {
              "type": "string"
            },
            "adminPassword": {
              "type": "securestring"
            },
            "location": {
              "type": "string"
            }
          },
          "variables": {
            "sqlServerName": "[concat('sql-', uniqueString(resourceGroup().id, 'sql'))]"
          },
          "resources": [
            {
              "type": "Microsoft.Sql/servers",
              "apiVersion": "2022-05-01-preview",
              "name": "[variables('sqlServerName')]",
              "location": "[parameters('location')]",
              "properties": {
                "administratorLogin": "[parameters('adminLogin')]",
                "administratorLoginPassword": "[parameters('adminPassword')]"
              }
            }
          ],
          "outputs": {
            "sqlFQDN": {
              "type": "string",
              "value": "[reference(variables('sqlServerName')).fullyQualifiedDomainName]"
            }
          }
        },
        "parameters": {
          "location": {
            "value": "[parameters('location')]"
          },
          "adminLogin": {
            "value": "ghuser"
          },
          "adminPassword": {
            "reference": {
              "keyVault": {
                "id": "[resourceId(parameters('vaultSubscription'), parameters('vaultResourceGroupName'), 'Microsoft.KeyVault/vaults', parameters('vaultName'))]"
              },
              "secretName": "[parameters('secretName')]"
            }
          }
        }
      }
    }
  ],
  "outputs": {
  }
}

다음 단계

Managed Application을 배포하는 동안 액세스할 수 있도록 Key Vault를 구성했습니다.