자습서: Media Services 관리 ID로 스토리지에 액세스

Media Services 로고 v3


경고

Azure Media Services는 2024년 6월 30일에 사용 중지됩니다. 자세한 내용은 AMS 사용 중지 가이드를 참조하세요.

참고

관리 ID는 v3 API를 사용하여 만든 Media Services 계정에만 사용할 수 있습니다. v2 API를 사용 중이며 관리 ID를 사용하려는 경우 v2에서 v3으로 마이그레이션합니다. Media Services v2에서 v3으로 마이그레이션 소개를 참조하세요.

스토리지 계정이 알 수 없는 IP 주소의 요청을 차단하도록 구성된 경우 스토리지 계정에 액세스하려면 Media Services 계정에 스토리지 계정에 대한 액세스 권한이 부여되어야 합니다. 아래 단계에 따라 Media Services 계정에 대한 관리 ID를 만들고 Media Services CLI를 사용하여 이 ID에 스토리지에 대한 액세스 권한을 부여합니다.

Media Services 계정은 관리 ID를 사용하여 스토리지에 액세스합니다.

이 자습서에서는 2020-05-01 Media Services API를 사용합니다.

개요

경고

Media Services 계정과 연결되지 않은 스토리지 계정에서는 JobInputHTTP 또는 SAS URL을 사용할 수 없습니다. 공용 서버에 미디어 파일이 있거나 다른 클라우드 공급자와 함께 저장된 경우와 같이 HTTP를 사용하여 액세스할 수 있는 기존 콘텐츠가 있는 고객의 편의를 위해 제공됩니다. 새 솔루션을 빌드하는 경우 작업 입력에 자산을 사용합니다.

Media Services에서 사용하는 스토리지 계정에 대한 액세스를 보호하려면 다음을 수행합니다.

  • 모든 IP 주소를 거부하도록 스토리지 계정을 구성(또는 고객 네트워크의 IP 주소만 허용)
  • "AzureServices"에 대한 액세스를 허용하도록 스토리지 계정 구성
  • Media Services가 관리 ID를 사용하여 스토리지 계정에 액세스하도록 구성
  • Media Services 자산에 미디어 콘텐츠 업로드
  • Media Services 자산을 작업 입력으로 사용하는 인코딩 작업 만들기 SAS URLS 또는 JobInputHTTP를 사용하지 마세요.

Azure에 로그인

이 문서의 명령을 사용하려면 먼저 사용하려는 구독에 로그인해야 합니다.

Azure에 로그인합니다. 이 명령을 사용하는 경우 사용하려는 구독을 묻는 메시지가 표시됩니다.

az login

구독 설정

이 명령을 사용하여 작업할 구독을 설정합니다.

CLI를 사용하여 Azure 구독 설정

다음 명령에서 Media Services 계정에 사용할 Azure 구독 ID를 제공합니다.

az account set --subscription <subscriptionName>

리소스 이름

시작하기 전에 만들려는 리소스의 이름을 결정합니다. 하나의 집합으로 쉽게 식별할 수 있어야 합니다. 특히 테스트를 마친 후에 사용할 계획이 없다면 더 필요합니다. 명명 규칙은 다양한 리소스 유형에 따라 다르므로 모두 소문자를 사용하는 것이 가장 좋습니다. 예를 들어, 리소스 그룹 이름은 "mediatest1rg", 스토리지 계정 이름은 "mediatest1stor"를 사용합니다. 이 문서의 각 단계에 동일한 이름을 사용합니다.

아래 명령에서 이러한 이름이 참조된 것을 볼 수 있습니다. 필요한 리소스의 이름은 다음과 같습니다.

  • myRG
  • myStorageAccount
  • myAmsAccount
  • 위치

참고

위의 하이픈은 안내 단어를 구분하는 데만 사용됩니다. Azure 서비스에서 리소스 이름 지정이 불일치하기 때문에 리소스 이름을 지정할 때는 하이픈을 사용하지 마십시오. 또한 지역 이름은 사용자가 만들지 않습니다. 지역 이름은 Azure에서 결정합니다.

Azure 지역 나열

사용할 실제 지역 이름을 잘 모르는 경우 다음 명령을 사용하여 목록을 표시합니다.

이 명령을 사용하여 계정에 사용할 수 있는 지역을 나열합니다.

az account list-locations --query "[].{DisplayName:displayName, Name:name}" -o table

시퀀스

아래의 각 단계는 특정 순서로 수행됩니다. JSON 응답의 값 하나 이상이 시퀀스의 다음 단계에서 사용되기 때문입니다.

Storage 계정 만들기

직접 만들 Media Services 계정에는 스토리지 계정이 연결되어 있어야 합니다. 먼저 Media Services 계정에 대한 스토리지 계정을 만듭니다. 후속 단계에서는 myStorageAccount를 대체하는 스토리지 계정 이름을 사용합니다.

CLI를 사용하여 Azure Storage 계정 만들기

다음 명령을 사용하여 Azure Storage 계정을 만들 수 있습니다.

스토리지 계정을 만들려면 먼저 위치 내에 리소스 그룹을 만들어야 합니다.

사용 가능한 위치를 나열하려면 다음 명령을 사용합니다.

CLI를 사용하여 사용 가능한 위치 나열

사용 가능한 위치를 나열하려면 다음 명령을 사용합니다.

az account list-locations

CLI를 사용하여 리소스 그룹 만들기

리소스 그룹을 만들려면 다음 명령을 사용합니다.

az group create -n <resourceGroupName> --location chooseLocation

SKU 선택

스토리지 계정의 SKU도 선택해야 합니다. 스토리지 계정을 나열할 수 있습니다.

Standard_LRS, Standard_GRS, Standard_RAGRS, Standard_ZRS, Premium_LRS, Premium_ZRS, Standard_GZRS, Standard_RAGZRS 목록에서 SKU를 선택합니다.

  • myStorageAccount를 길이가 24자 미만인 고유 이름으로 변경합니다.
  • chooseLocation을 작업하려는 지역으로 변경합니다.
  • chooseSKU를 선호하는 SKU로 변경합니다.
az storage account create -n <myStorageAccount> -g <resourceGroup>  --location <chooseLocation> --sku <chooseSKU>

서비스 주체(관리 ID)를 사용하여 Media Services 계정 만들기

이제 관리 ID라고도 하는 서비스 주체를 사용하여 Media Services 계정을 만듭니다.

중요

명령에서 --mi 플래그를 사용하는 것을 기억해야 합니다. 그렇지 않으면 이후 단계를 위한 principalId를 찾을 수 없습니다.

다음 Azure CLI 명령은 새 Media Services 계정을 만듭니다. your-media-services-account-name, your-storage-account-name, your-resource-group-name 값을 사용하려는 이름으로 바꿉니다. 이 명령은 리소스 그룹 및 스토리지 계정을 이미 만들었다고 가정합니다.

Media Services 계정에 --mi-system-assigned 플래그가 있는 시스템 할당 관리 ID를 제공합니다.


az ams account create --name <your-media-services-account-name> --resource-group <your-resource-group-name> --mi-system-assigned --storage-account <your-storage-account-name>

예제 JSON 응답:

{
  "encryption": {
    "keyVaultProperties": null,
    "type": "SystemKey"
  },
  "id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/your-resource-group/providers/Microsoft.Media/mediaservices/your-media-services-account-name",
  "identity": {
    "principalId": "00000000-0000-0000-0000-00000000",
    "tenantId": "00000000-0000-0000-0000-00000000",
    "type": "SystemAssigned"
  },
  "location": "your-region",
  "mediaServiceId": "00000000-0000-0000-0000-00000000",
  "name": "your-media-services-account-name",
  "resourceGroup": "your-resource-group",
  "storageAccounts": [
    {
      "id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/mediatest1rg/providers/Microsoft.Storage/storageAccounts/your-storage-account-name",
      "resourceGroup": "your-resource-group",
      "type": "Primary"
    }
  ],
  "storageAuthentication": "System",
  "systemData": {
    "createdAt": "2021-05-14T21:25:12.3492071Z",
    "createdBy": "you@example.com",
    "createdByType": "User",
    "lastModifiedAt": "2021-05-14T21:25:12.3492071Z",
    "lastModifiedBy": "you@example.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "Microsoft.Media/mediaservices"
}

스토리지 계정에 Media Services 관리 ID 액세스 권한 부여

스토리지 계정에 Media Services 관리 ID 액세스 권한을 부여합니다. 세 가지 명령이 있습니다.

Media Services 계정의 관리 ID 가져오기(표시)

아래의 첫 번째 명령은 Media Services 계정의 관리 ID 즉, 명령에서 반환된 JSON에 나열된 principalId를 보여줍니다.

이 명령은 Media Services 계정의 모든 속성을 표시합니다.

az ams account show --name <your-media-services-account-name> --resource-group <your-resource-group>

참고

Media Services 계정에 액세스 역할을 할당한 경우 이 줄은 "storageAuthentication": "ManagedIdentity"를 반환합니다.

예제 JSON 응답:

{
  "encryption": {
    "keyVaultProperties": null,
    "type": "SystemKey"
  },
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Media/mediaservices/your-media-services-account",
  "identity": {
    "principalId": "00000000-0000-0000-0000-000000000000",
    "tenantId": "00000000-0000-0000-0000-000000000000",
    "type": "SystemAssigned"  //Type will show "Managed Identity" if you have assigned a role to the Media Services account.
  },
  "location": "your-region",
  "mediaServiceId": "00000000-0000-0000-0000-000000000000",
  "name": "your-media-services-account",
  "resourceGroup": "your-resource-group-name",
  "storageAccounts": [
    {
      "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name",
      "resourceGroup": "your-resource-group-name",
      "type": "Primary"
    }
  ],
  "storageAuthentication": "System", //If you have assigned access roles to the account, this line will return storageAuthentication": "ManagedIdentity"
  "systemData": {
    "createdAt": "2021-05-14T21:25:12.3492071Z",
    "createdBy": "you@example.com",
    "createdByType": "User",
    "lastModifiedAt": "2021-05-14T21:25:12.3492071Z",
    "lastModifiedBy": "you@example.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "Microsoft.Media/mediaservices"
}

Storage Blob 기여자 역할 할당 만들기

다음 명령은 Storage Blob 기여자 역할을 만듭니다.

assigneeprincipalId로 변경합니다. 이 명령은 리소스 그룹 및 스토리지 계정을 이미 만들었다고 가정합니다. 아래 명령과 같이 your-resource-group-nameyour-storage-account-namescope 값의 일부로 사용합니다.

az role assignment create --assignee 00000000-0000-0000-000000000000 --role "Storage Blob Data Contributor" --scope "/subscriptions/00000000-0000-0000-000000000000/resourceGroups/<your-resource-group-name>/providers/Microsoft.Storage/storageAccounts/<your-storage-account-name>"

예제 JSON 응답:

{
  "canDelegate": null,
  "condition": null,
  "conditionVersion": null,
  "description": null,
  "id": "/subscriptions/00000000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-000000000000",
  "name": "00000000-0000-0000-000000000000",
  "principalId": "00000000-0000-0000-000000000000",
  "principalType": "ServicePrincipal",
  "resourceGroup": "your-resource-group-name",
  "roleDefinitionId": "/subscriptions/00000000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-000000000000",
  "scope": "/subscriptions/00000000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name",
  "type": "Microsoft.Authorization/roleAssignments"
}

reader 역할 할당 만들기

다음 명령은 읽기 권한자 역할을 만듭니다.

assigneeprincipalId로 변경합니다. 이 명령은 리소스 그룹 및 스토리지 계정을 이미 만들었다고 가정합니다. 아래 명령과 같이 your-resource-group-nameyour-storage-account-namescope 값의 일부로 사용합니다.

az role assignment create --assignee 00000000-0000-0000-000000000000 --role "Reader" --scope "/subscriptions/00000000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name"

예제 JSON 응답:

{
  "canDelegate": null,
  "condition": null,
  "conditionVersion": null,
  "description": null,
  "id": "/subscriptions/00000000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-000000000000",
  "name": "00000000-0000-0000-000000000000",
  "principalId": "00000000-0000-0000-000000000000",
  "principalType": "Reader",
  "resourceGroup": "your-resource-group-name",
  "roleDefinitionId": "/subscriptions/00000000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-000000000000",
  "scope": "/subscriptions/00000000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name",
  "type": "Microsoft.Authorization/roleAssignments"
}

관리 ID를 사용하여 스토리지 계정에 액세스

다음 명령은 스토리지 계정에 대한 Media Services 관리 ID 액세스 권한을 제공합니다.

아래 명령에서 your-resource-group-name을 리소스 그룹 이름으로 변경하고 your-media-services-account-name을 작업할 Media Services 계정 이름으로 변경합니다.

az ams account storage set-authentication --storage-auth ManagedIdentity --resource-group <your-resource-group_name> --account-name <your-media-services-account-name>

예제 JSON 응답:

{
  "encryption": {
    "keyVaultProperties": null,
    "type": "SystemKey"
  },
  "id": "/subscriptions/00000000-0000-0000-00000000/resourceGroups/your-resource-group-name/providers/Microsoft.Media/mediaservices/your-storage-account-name",
  "identity": null,
  "location": "West US 2",
  "mediaServiceId": "00000000-0000-0000-00000000",
  "name": "your-media-services-account",
  "resourceGroup": "your-resource-group-name",
  "storageAccounts": [
    {
      "id": "/subscriptions/2b461b25-f7b4-4a22-90cc-d640a14b5471/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name",
      "resourceGroup": "your-resource-group-name",
      "type": "Primary"
    }
  ],
  "storageAuthentication": "ManagedIdentity",
  "systemData": {
    "createdAt": "2021-05-17T19:15:00.8850297Z",
    "createdBy": "you@example.com",
    "createdByType": "User",
    "lastModifiedAt": "2021-05-17T21:23:11.3863627Z",
    "lastModifiedBy": "you@example.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "Microsoft.Media/mediaservices"
}

유효성 검사

고객 관리형 키를 사용하여 계정이 암호화되었는지 확인하려면 계정 암호화 속성을 확인합니다.

이 명령은 Media Services 계정의 모든 속성을 표시합니다.

az ams account show --name <your-media-services-account-name> --resource-group <your-resource-group>

참고

Media Services 계정에 액세스 역할을 할당한 경우 이 줄은 "storageAuthentication": "ManagedIdentity"를 반환합니다.

예제 JSON 응답:

{
  "encryption": {
    "keyVaultProperties": null,
    "type": "SystemKey"
  },
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Media/mediaservices/your-media-services-account",
  "identity": {
    "principalId": "00000000-0000-0000-0000-000000000000",
    "tenantId": "00000000-0000-0000-0000-000000000000",
    "type": "SystemAssigned"  //Type will show "Managed Identity" if you have assigned a role to the Media Services account.
  },
  "location": "your-region",
  "mediaServiceId": "00000000-0000-0000-0000-000000000000",
  "name": "your-media-services-account",
  "resourceGroup": "your-resource-group-name",
  "storageAccounts": [
    {
      "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/your-resource-group-name/providers/Microsoft.Storage/storageAccounts/your-storage-account-name",
      "resourceGroup": "your-resource-group-name",
      "type": "Primary"
    }
  ],
  "storageAuthentication": "System", //If you have assigned access roles to the account, this line will return storageAuthentication": "ManagedIdentity"
  "systemData": {
    "createdAt": "2021-05-14T21:25:12.3492071Z",
    "createdBy": "you@example.com",
    "createdByType": "User",
    "lastModifiedAt": "2021-05-14T21:25:12.3492071Z",
    "lastModifiedBy": "you@example.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "Microsoft.Media/mediaservices"
}

storageAuthentication 속성에 "ManagedIdentity"가 표시되어야 합니다.

추가 유효성 검사를 위해 Azure Storage 로그를 확인하여 각 요청에 사용되는 인증 방법을 확인할 수 있습니다.

리소스 정리

직접 만든 리소스를 사용할 계획이 없으면 리소스 그룹을 삭제합니다.

CLI를 사용하여 리소스 그룹 삭제

az group delete --name <your-resource-group-name>

도움말 및 지원 보기

다음 방법 중 하나로 Media Services에 문의하거나 업데이트를 따를 수 있습니다.