Microsoft Entra ID로 Azure Cosmos DB 계정에 대한 관리 ID 구성

적용 대상: NoSQL MongoDB Cassandra Gremlin 테이블

Azure 리소스의 관리 ID는 Microsoft Entra ID에서 자동으로 관리되는 ID를 Azure 서비스에 제공합니다. 이 문서에서는 Azure Cosmos DB 계정에 대한 관리 ID를 만드는 방법을 보여줍니다.

필수 조건

시스템 할당 ID 추가

Azure 포털 사용하기

기존 Azure Cosmos DB 계정에서 시스템이 할당한 관리 ID를 사용하도록 설정하려면 Azure Portal에서 계정으로 이동하고 왼쪽 메뉴에서 ID를 선택합니다.

The Identity menu entry

시스템 할당 섹션에서 상태를 켜기로 전환하고 저장을 선택합니다. 시스템이 할당한 관리 ID 생성을 확인하라는 메시지가 표시됩니다.

Enabling a system-assigned identity

ID를 만들어 할당하면 해당 개체(보안 주체) ID를 검색할 수 있습니다.

Retrieving the object ID of a system-assigned identity

ARM(Azure Resource Manager) 템플릿 사용

Important

관리 ID로 작업할 때는 2021-03-15 이상의 apiVersion을 사용해야 합니다.

신규 또는 기존 Azure Cosmos DB 계정에서 시스템 할당 ID를 사용하도록 설정하려면 리소스 정의에 다음 속성을 포함합니다.

"identity": {
    "type": "SystemAssigned"
}

ARM 템플릿의 resources 섹션은 다음과 같아야 합니다.

"resources": [
    {
        "type": " Microsoft.DocumentDB/databaseAccounts",
        "identity": {
            "type": "SystemAssigned"
        },
        // ...
    },
    // ...
]

Azure Cosmos DB 계정이 생성되거나 업데이트되면 다음 속성이 표시됩니다.

"identity": {
    "type": "SystemAssigned",
    "tenantId": "<azure-ad-tenant-id>",
    "principalId": "<azure-ad-principal-id>"
}

Azure CLI 사용

새 Azure Cosmos DB 계정을 만드는 동안 시스템 할당 ID를 사용하도록 설정하려면 --assign-identity 옵션을 추가합니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb create \
    -n $accountName \
    -g $resourceGroupName \
    --locations regionName='West US 2' failoverPriority=0 isZoneRedundant=False \
    --assign-identity

az cosmosdb identity assign 명령을 사용하여 기존 계정에 시스템 할당 ID를 추가할 수도 있습니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb identity assign \
    -n $accountName \
    -g $resourceGroupName

Azure Cosmos DB 계정이 만들어지거나 업데이트된 후에는 az cosmosdb identity show 명령을 사용하여 할당된 ID를 가져올 수 있습니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb identity show \
    -n $accountName \
    -g $resourceGroupName
{
    "type": "SystemAssigned",
    "tenantId": "<azure-ad-tenant-id>",
    "principalId": "<azure-ad-principal-id>"
}

사용자 할당 ID 추가

Azure 포털 사용하기

기존 Azure Cosmos DB 계정에서 사용자가 할당한 관리 ID를 사용하도록 설정하려면 Azure Portal에서 계정으로 이동하고 왼쪽 메뉴에서 ID를 선택합니다.

The Identity menu entry

사용자 할당 섹션에서 + 추가를 선택합니다.

Enabling a user-assigned identity

Azure Cosmos DB 계정에 할당할 모든 ID를 찾아 선택한 다음 추가를 선택합니다.

Selecting all the identities to assign

ARM(Azure Resource Manager) 템플릿 사용

Important

관리 ID로 작업할 때는 2021-03-15 이상의 apiVersion을 사용해야 합니다.

신규 또는 기존 Azure Cosmos DB 계정에서 사용자가 할당한 ID를 사용하도록 설정하려면 리소스 정의에 다음 속성을 포함합니다.

"identity": {
    "type": "UserAssigned",
    "userAssignedIdentities": {
        "<identity-resource-id>": {}
    }
}

ARM 템플릿의 resources 섹션은 다음과 같아야 합니다.

"resources": [
    {
        "type": " Microsoft.DocumentDB/databaseAccounts",
        "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": {
                "<identity-resource-id>": {}
            }
        },
        // ...
    },
    // ...
]

Azure Cosmos DB 계정이 생성되거나 업데이트되면 다음 속성이 표시됩니다.

"identity": {
    "type": "UserAssigned",
    "tenantId": "<azure-ad-tenant-id>",
    "principalId": "<azure-ad-principal-id>"
}

Azure CLI 사용

새 Azure Cosmos DB 계정을 만드는 동안 사용자가 할당한 ID를 사용하도록 설정하려면 --assign-identity 옵션을 추가하고 할당할 ID의 리소스 ID를 전달합니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb create \
    -n $accountName \
    -g $resourceGroupName \
    --locations regionName='West US 2' failoverPriority=0 isZoneRedundant=False \
    --assign-identity <identity-resource-id>

az cosmosdb identity assign 명령을 사용하여 기존 계정에 사용자가 할당한 ID를 추가할 수도 있습니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb identity assign \
    -n $accountName \
    -g $resourceGroupName
    --identities <identity-resource-id>

Azure Cosmos DB 계정이 만들어지거나 업데이트된 후에는 az cosmosdb identity show 명령을 사용하여 할당된 ID를 가져올 수 있습니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb identity show \
    -n $accountName \
    -g $resourceGroupName
{
    "type": "UserAssigned",
    "tenantId": "<azure-ad-tenant-id>",
    "principalId": "<azure-ad-principal-id>"
}

시스템이 할당한 ID 또는 사용자가 할당한 ID 제거

ARM(Azure Resource Manager) 템플릿 사용

Important

관리 ID로 작업할 때는 2021-03-15 이상의 apiVersion을 사용해야 합니다.

Azure Cosmos DB 계정에서 시스템 할당 ID를 제거하려면 identity 속성의 typeNone으로 설정합니다.

"identity": {
    "type": "None"
}

Azure CLI 사용

Azure Cosmos DB 계정에서 모든 관리 ID를 제거하려면 az cosmosdb identity remove 명령을 사용합니다.

resourceGroupName='myResourceGroup'
accountName='mycosmosaccount'

az cosmosdb identity remove \
    -n $accountName \
    -g $resourceGroupName

다음 단계