Aracılığıyla paylaş


Öğretici: Media Services güvenilen depolama alanı

Media Services logosu v3


Uyarı

Azure Media Services 30 Haziran 2024'de kullanımdan kaldırılacak. Daha fazla bilgi için bkz. AMS Kullanımdan Kaldırma Kılavuzu.

Bu öğreticide şunları öğreneceksiniz:

  • Azure Media Services için güvenilen depolamayı etkinleştirme
  • Güvenilen depolama için Yönetilen Kimlikleri kullanma
  • Güvenlik duvarı veya VPN gibi ağ erişim denetimi kullanılırken Azure Hizmetleri'ne depolama hesabına erişim izni verme

2020-05-01 API'siyle, Yönetilen Kimliği bir Media Services hesabıyla ilişkilendirerek güvenilen depolamayı etkinleştirebilirsiniz.

Not

Güvenilen depolama yalnızca API'de kullanılabilir ve şu anda Azure portal etkin değildir.

Media Services, sistem kimlik doğrulaması kullanarak depolama hesabınıza otomatik olarak erişebilir. Media Services, ilişkilendirmeyi ekleyen kullanıcının Azure Resource Manager RBAC ile depolama hesabına eriştiğini doğrular.

Abonelikler arası depolama hesaplarının kullanımı

Not

Media Services, depolamaya erişmek için Yönetilen Kimlik kullanacak şekilde yapılandırıldığında, Media Services Yönetilen Kimliğin erişebileceği herhangi bir depolama hesabını kullanabilir.

Depolama için Sistem kimlik doğrulaması kullanılırken, depolama hesabının Media Services hesabıyla aynı abonelikte olması gerekir. Ek veri çıkışı maliyetlerini önlemek için Media Services hesabıyla aynı bölgedeki depolama hesaplarını kullanın.

Her iki kimlik doğrulama türü için de Media Services hesabını oluşturan veya güncelleştiren sorumlunun depolama hesabı üzerinde 'Microsoft.Storage/storageAccounts/listkeys/action' izni olmalıdır.

Genel Bakış

Önemli

Media Services'e yönelik tüm istekler için 2020-05-01 API'sini kullanın.

Media Services için güvenilen depolama alanı oluşturmaya yönelik genel adımlar şunlardır:

  1. Bir kaynak grubu oluşturun.
  2. Depolama hesabı oluşturma.
  3. Depolama hesabını hazır olana kadar yoklayın. Depolama hesabı hazır olduğunda istek hizmet sorumlusu kimliğini döndürür.
  4. Depolama Blobu Veri Katkıda Bulunanı rolünün kimliğini bulun.
  5. Yetkilendirme sağlayıcısını çağırın ve bir rol ataması ekleyin.
  6. Yönetilen Kimlik kullanarak depolama hesabında kimlik doğrulaması yapmak için media services hesabını güncelleştirin.
  7. Kullanmaya devam etmek istemiyorsanız kaynakları silin ve bunlar için ücret alın.

Önkoşullar

Başlamak için bir Azure aboneliğine ihtiyacınız vardır. Azure aboneliğiniz yoksa ücretsiz bir deneme hesabı oluşturun.

Kiracı kimliğinizi ve abonelik kimliğinizi alma

Kiracı kimliğinizi ve abonelik kimliğinizi nasıl alabileceğinizi bilmiyorsanız bkz. Aboneliğinizi ve kiracı kimliğinizi bulma.

Hizmet sorumlusu ve gizli dizi oluşturma

Hizmet sorumlusu ve gizli dizi oluşturmayı bilmiyorsanız bkz. Media Services API'sine erişmek için kimlik bilgilerini alma.

REST istemcisi kullanma

Bu betik, Visual Studio code uzantılarında sağlananlar gibi bir REST istemcisiyle kullanıma yöneliktir. Geliştirme ortamınız için uyarlayın.

başlangıç değişkenlerini ayarlama

Betiğin bu bölümü rest istemcisinde kullanılır. Geliştirme ortamınızda değişkenleri farklı kullanabilirsiniz.

### AAD details
@tenantId = your tenant ID
@servicePrincipalId = the service principal ID
@servicePrincipalSecret = the service principal secret

### AAD resources
@armResource = https%3A%2F%2Fmanagement.core.windows.net%2F
@graphResource = https%3A%2F%2Fgraph.windows.net%2F
@storageResource = https%3A%2F%2Fstorage.azure.com%2F

### Service endpoints
@armEndpoint = management.azure.com
@graphEndpoint = graph.windows.net
@aadEndpoint = login.microsoftonline.com

### ARM details
@subscription = your subscription id
@resourceGroup = the resource group you'll be creating
@storageName = the name of the storage you'll be creating
@accountName = the name of the account you'll be creating
@resourceLocation = East US (or the location that works best for your region)

Azure Resource Manager için belirteç alma

// @name getArmToken
POST https://{{aadEndpoint}}/{{tenantId}}/oauth2/token
Accept: application/json
Content-Type: application/x-www-form-urlencoded

resource={{armResource}}&client_id={{servicePrincipalId}}&client_secret={{servicePrincipalSecret}}&grant_type=client_credentials

Graph API için belirteç alma

Betiğin bu bölümü rest istemcisinde kullanılır. Geliştirme ortamınızda değişkenleri farklı kullanabilirsiniz.

// @name getGraphToken
POST https://{{aadEndpoint}}/{{tenantId}}/oauth2/token
Accept: application/json
Content-Type: application/x-www-form-urlencoded

resource={{graphResource}}&client_id={{servicePrincipalId}}&client_secret={{servicePrincipalSecret}}&grant_type=client_credentials

Hizmet sorumlusu ayrıntılarını alma

// @name getServicePrincipals
GET https://{{graphEndpoint}}/{{tenantId}}/servicePrincipals?$filter=appId%20eq%20'{{servicePrincipalId}}'&api-version=1.6
x-ms-client-request-id: cae3e4f7-17a0-476a-a05a-0dab934ba959
Authorization:  Bearer {{getGraphToken.response.body.access_token}}

Hizmet sorumlusu kimliğini depolama

@servicePrincipalObjectId = {{getServicePrincipals.response.body.value[0].objectId}}

Kaynak grubu oluşturma

// @name createResourceGroup
PUT https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}
    ?api-version=2016-09-01
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
    "location": "{{resourceLocation}}"
}

Depolama hesabı oluştur

// @name createStorageAccount
PUT https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}
    ?api-version=2019-06-01
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
    "sku": {
    "name": "Standard_GRS"
    },
    "kind": "StorageV2",
    "location": "{{resourceLocation}}",
    "properties": {
    }
}

Depolama hesabı durumunu alma

Depolama hesabının hazır olması biraz zaman alır, bu nedenle bu istek durumunu yoklar. Depolama hesabı hazır olana kadar bu isteği yineleyin.

// @name getStorageAccountStatus
GET {{createStorageAccount.response.headers.Location}}
Authorization: Bearer {{getArmToken.response.body.access_token}}

Depolama hesabı ayrıntılarını alma

Depolama hesabı hazır olduğunda depolama hesabının özelliklerini alın.

// @name getStorageAccount
GET https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}
    ?api-version=2019-06-01
Authorization: Bearer {{getArmToken.response.body.access_token}}

ARM için belirteç alma

// @name getStorageToken
POST https://{{aadEndpoint}}/{{tenantId}}/oauth2/token
Accept: application/json
Content-Type: application/x-www-form-urlencoded

resource={{storageResource}}&client_id={{servicePrincipalId}}&client_secret={{servicePrincipalSecret}}&grant_type=client_credentials

Sistem tarafından atanan yönetilen kimlikle Media Services hesabı oluşturma

// @name createMediaServicesAccount
PUT https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Media/mediaservices/{{accountName}}?api-version=2020-05-01
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
  "identity": {
      "type": "SystemAssigned"
  },
  "properties": {
    "storageAccounts": [
      {
        "id": "{{getStorageAccountStatus.response.body.id}}"
      }
    ],
    "encryption": {
      "type": "SystemKey"
    }
  },
  "location": "{{resourceLocation}}"
}

Depolama Depolama Blob Verileri rol tanımını alma

// @name getStorageBlobDataContributorRoleDefinition
GET https://management.azure.com/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName%20eq%20%27Storage%20Blob%20Data%20Contributor%27&api-version=2015-07-01
Authorization: Bearer {{getArmToken.response.body.access_token}}

Depolama rolü atamasını ayarlama

Rol ataması, Media Services hesabının hizmet sorumlusunun Depolama Blob Verileri Katkıda Bulunanı depolama rolüne sahip olduğunu söyler. Bu işlem biraz zaman alabilir ve beklemeniz önemlidir, aksi halde Media Services hesabı doğru ayarlanamaz.

PUT https://management.azure.com/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}/providers/Microsoft.Authorization/roleAssignments/{{$guid}}?api-version=2020-04-01-preview
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
  "properties": {
    "roleDefinitionId": "/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}/providers/Microsoft.Authorization/roleDefinitions/{{getStorageBlobDataContributorRoleDefinition.response.body.value[0].name}}",
    "principalId": "{{createMediaServicesAccount.response.body.identity.principalId}}"
  }
}

Yönetilen Kimliğe depolama hesabına atlama erişimi verme

Bu eylem, sistem tarafından yönetilen kimlikten Yönetilen Kimliğe erişimi değiştirir. Bu şekilde, Azure hizmetleri IP erişim kurallarından (ACL) bağımsız olarak depolama hesabına erişebildiği için depolama hesabı bir güvenlik duvarı üzerinden depolama hesabına erişebilir.

Bir kez daha, rol depolama hesabında atanana kadar bekleyin; aksi takdirde Media Services hesabı yanlış ayarlanır.

// @name setStorageAccountFirewall
PUT https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}
    ?api-version=2019-06-01
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
    "sku": {
    "name": "Standard_GRS"
    },
    "kind": "StorageV2",
    "location": "{{resourceLocation}}",
    "properties": {
      "minimumTlsVersion": "TLS1_2",
      "networkAcls": {
        "bypass": "AzureServices",
        "virtualNetworkRules": [],
        "ipRules": [],
        "defaultAction": "Deny"
      }
    }
}

Media Services hesabını Yönetilen Kimliği kullanacak şekilde güncelleştirme

Depolama rolü atamasının yayılması birkaç dakika olabileceğinden bu isteğin birkaç kez yeniden denenmiş olması gerekebilir.

// @name updateMediaServicesAccountWithManagedStorageAuth
PUT https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Media/mediaservices/{{accountName}}?api-version=2020-05-01
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
  "identity": {
      "type": "SystemAssigned"
  },
  "properties": {
    "storageAccounts": [
      {
        "id": "{{getStorageAccountStatus.response.body.id}}"
      }
    ],
    "storageAuthentication": "ManagedIdentity",
    "encryption": {
      "type": "SystemKey"
    }
  },
  "location": "{{resourceLocation}}"
}

Erişimi test et

Depolama hesabında bir varlık oluşturarak erişimi test edin.

// @name createAsset
PUT https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Media/mediaservices/{{accountName}}/assets/testasset{{index}}withoutmi?api-version=2018-07-01
Authorization: Bearer {{getArmToken.response.body.access_token}}
Content-Type: application/json; charset=utf-8

{
}

Kaynakları silme

Oluşturduğunuz kaynakları korumak ve bunlar için ücretlendirilmeye devam etmek istemiyorsanız silin.

### Clean up the Storage account
DELETE https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Storage/storageAccounts/{{storageName}}
    ?api-version=2019-06-01
Authorization: Bearer {{getArmToken.response.body.access_token}}

### Clean up the Media Services account
DELETE https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Media/mediaservices/{{accountName}}?api-version=2020-05-01
Authorization: Bearer {{getArmToken.response.body.access_token}}

### Clean up the Media Services account
GET https://{{armEndpoint}}/subscriptions/{{subscription}}/resourceGroups/{{resourceGroup}}/providers/Microsoft.Media/mediaservices/{{accountName}}?api-version=2020-05-01
Authorization: Bearer {{getArmToken.response.body.access_token}}

Yardım ve destek alma

Sorularınız için Media Services ile iletişime geçebilir veya aşağıdaki yöntemlerden birini kullanarak güncelleştirmelerimizi izleyebilirsiniz: