BLOB 데이터에 대한 익명 읽기 권한 문제 수정(클래식 배포)

Azure Blob Storage는 컨테이너 및 BLOB에 대한 선택적 익명 읽기 권한을 지원합니다. 그러나 익명 액세스는 보안 위험을 초래할 수 있습니다. 최적의 보안을 위해 익명 액세스를 사용하지 않도록 설정하는 것이 좋습니다. 익명 액세스를 허용하지 않으면 원치 않는 익명 액세스로 인한 데이터 위반을 방지할 수 있습니다.

기본적으로 BLOB 데이터에 대한 공용 액세스는 항상 금지됩니다. 하지만, 클래식 스토리지 계정의 기본 구성을 사용하면 적절한 권한이 있는 사용자가 스토리지 계정의 컨테이너 및 BLOB에 대한 익명 액세스를 구성할 수 있습니다. 클래식 스토리지 계정에 대한 익명 액세스를 방지하려면 공용 액세스를 차단하도록 계정의 각 컨테이너를 구성해야 합니다.

스토리지 계정이 클래식 배포 모델을 사용하는 경우 가능한 한 빨리 Azure Resource Manager 배포 모델로 마이그레이션하는 것이 좋습니다. 계정을 마이그레이션한 후 계정 수준에서 익명 액세스를 허용하지 않도록 구성할 수 있습니다. Azure Resource Manager 계정에 대한 익명 액세스를 허용하지 않는 방법에 대한 자세한 내용은 BLOB 데이터에 대한 익명 읽기 권한 수정(Azure Resource Manager 배포)을 참조하세요.

지금 클래식 스토리지 계정을 마이그레이션할 수 없는 경우 지금 모든 컨테이너를 프라이빗으로 설정하여 해당 계정에 대한 익명 액세스를 수정해야 합니다. 이 문서에서는 클래식 스토리지 계정의 컨테이너에 대한 액세스를 수정하는 방법을 설명합니다.

클래식 배포 모델을 사용하는 Azure Storage 계정은 2024년 8월 31일에 만료됩니다. 자세한 내용은 Azure 클래식 스토리지 계정이 2024년 8월 31일에 사용 중지됨을 참조하세요.

Warning

익명 액세스는 보안 위험을 초래합니다. 시나리오에 특별히 익명 액세스가 필요한 경우가 아니면 다음 섹션에 설명된 작업을 수행하여 모든 클래식 스토리지 계정에 대한 익명 액세스를 수정하는 것이 좋습니다.

컨테이너에 대한 익명 액세스 차단

클래식 스토리지 계정에 대한 익명 액세스를 수정하려면 계정의 각 컨테이너에 대한 익명 액세스 수준을 프라이빗으로 설정합니다.

Azure Portal에서 하나 이상의 컨테이너에 대한 익명 액세스를 수정하려면 다음 단계를 따릅니다.

  1. Azure Portal의 스토리지 계정 개요로 이동합니다.

  2. 메뉴 블레이드의 데이터 저장소에서 Blob 컨테이너를 선택합니다.

  3. 익명 액세스 수준을 설정하려는 컨테이너를 선택합니다.

  4. 액세스 수준 변경 단추를 사용하여 액세스 설정을 표시합니다.

  5. 익명 액세스 수준 드롭다운에서 프라이빗(익명 액세스 없음)을 선택하고 확인 단추를 클릭하여 선택한 컨테이너에 변경 내용을 적용합니다.

    Screenshot showing how to set anonymous access level in the portal.

컨테이너 집합에 대한 익명 액세스 설정 확인

컨테이너를 나열하고 익명 액세스 설정을 확인하여 하나 이상의 스토리지 계정에서 어떤 컨테이너가 익명 액세스를 위해 구성되었는지 확인할 수 있습니다. 이 방법은 스토리지 계정에 많은 수의 컨테이너가 포함되어 있지 않거나 소수의 스토리지 계정에서 설정을 확인하는 경우에 유용한 옵션입니다. 그러나 많은 수의 컨테이너를 열거하려고 하면 성능이 저하될 수 있습니다.

다음 예제에서는 PowerShell을 사용하여 스토리지 계정의 모든 컨테이너에 대한 익명 액세스 설정을 가져옵니다. 대괄호의 자리 표시자 값을 사용자 고유의 값으로 바꿔야 합니다.

$rgName = "<resource-group>"
$accountName = "<storage-account>"

$storageAccount = Get-AzStorageAccount -ResourceGroupName $rgName -Name $accountName
$ctx = $storageAccount.Context

Get-AzStorageContainer -Context $ctx | Select Name, PublicAccess

대량 수정을 위한 샘플 스크립트

다음 샘플 PowerShell 스크립트는 구독의 모든 클래식 스토리지 계정에 대해 실행되며 해당 계정의 컨테이너에 대한 익명 액세스 설정을 프라이빗으로 설정합니다.

주의

매우 많은 수의 컨테이너가 있는 스토리지 계정에 대해 이 스크립트를 실행하면 상당한 리소스가 필요하고 시간이 오래 걸릴 수 있습니다. 매우 많은 수의 컨테이너가 포함된 스토리지 계정이 있는 경우 익명 액세스를 수정하기 위해 다른 방식을 고안할 수 있습니다.

# This script runs against all classic storage accounts in a single subscription
# and sets containers to private.

## IMPORTANT ##
# Running this script requires a connected account through the previous version 
# of Azure PowerShell. Use the following command to install:
# Install-Module Azure -scope CurrentUser -force
#
# Once installed, you will need to connect with:
# Add-AzureAccount
#
# This command may fail if there are modules installed that conflict with it.
# One known conflicting module is AzureRm.Accounts
# You will need to remove conflicting modules using the following:
# Remove-Module -name <name>
#
# The Azure PowerShell module assumes a current subscription when enumerating
# storage accounts.  You can set the current subscription with:
# Select-AzureSubscription -subscriptionId <subscriptionId>
#
# Get-AzureSubscription lists all subscriptions available to the Azure
# module. Not all subscriptions listed under your name in the portal may 
# appear here. If a subscription does not appear, you may need to use 
# the portal to remediate public access for those accounts.
# After you have selected your subscription, verify that it is current
# by running:
# Get-AzureSubscription -current
# 
# After the current subscription runs, you can run this script, change
# to another subscription after it completes, and then run again as necessary.
## END IMPORTANT##

# Standard operation will enumerate all accounts and check for containers with public 
# access, then allow the user to decide whether or not to disable the setting.  

# Run with BypassConfirmation=$true if you wish to remove permissions from all containers
# without individual confirmation

# Run with BypassArmUpgrade=$true if you wish to upgrade your storage account to use the 
# Azure Resource Manager deployment model. All accounts must be upgraded by 31 August 2024.

param(
    [boolean]$BypassConfirmation=$false,
    [boolean]$BypassArmUpgrade=$false
)

#Do not change this
$convertAccounts = $false

foreach($classicAccount in Get-AzureStorageAccount)
{
    $enumerate = $false

    if(!$BypassArmUpgrade)
    {
        write-host "Classic Storage Account" $classicAccount.storageAccountname "found"
        $confirmation = read-host "Convert to ARM? [y/n]:"
    }
    if(($confirmation -eq 'y') -and (!$BypassArmUpgrade))
    {
        write-host "Conversion selected"
        $convertAccounts = $true
    }
    else
    {
        write-host $classicAccount.StorageAccountName "conversion not selected.  Searching for public containers..."
        $enumerate = $true
    }

    if($enumerate)
    {
        foreach($container in get-azurestoragecontainer -context (get-azurestorageaccount -storageaccountname $classicAccount.StorageAccountName).context)
        {
            if($container.PublicAccess -eq 'Off')
            {
            } 
            else 
            {
                if(!$BypassConfirmation)
                {
                    $selection = read-host $container.Name $container.PublicAccess "access found, Make private?[y/n]:"
                }
                if(($selection -eq 'y') -or ($BypassConfirmation))
                {
                    write-host "Removing permissions from" $container.name "container on storage account" $classicaccount.StorageAccountName
                    try
                    {
                        Set-AzureStorageContainerAcl -context $classicAccount.context -name $container.name -Permission Off
                        write-host "Success!"
                    }
                    catch
                    {
                        $_
                    }
                }
                else
                {
                    write-host "Skipping..."
                }
            }
        }
    }
}
if($convertAccounts)
{
    write-host "Converting accounts to ARM is the preferred method, however there are some caveats."
    write-host "The preferred method would be to use the portal to perform the conversions and then "
    write-host "run the ARM script against them.  For more information on converting a classic account"
    write-host "to an ARM account, please see:"
    write-host "https://learn.microsoft.com/en-us/azure/virtual-machines/migration-classic-resource-manager-overview"
}
write-host "Script complete"

참고 항목