Создание политики потоковой передачи в учетной записи Служб мультимедиа
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}?api-version=2022-08-01
Параметры URI
Имя |
В |
Обязательно |
Тип |
Описание |
accountName
|
path |
True
|
string
|
Имя учетной записи Служб мультимедиа.
|
resourceGroupName
|
path |
True
|
string
|
Имя группы ресурсов в подписке Azure.
|
streamingPolicyName
|
path |
True
|
string
|
Имя политики потоковой передачи.
|
subscriptionId
|
path |
True
|
string
|
Уникальный идентификатор подписки Microsoft Azure.
|
api-version
|
query |
True
|
string
|
Версия API, которая будет использоваться с клиентским запросом.
|
Текст запроса
Имя |
Тип |
Описание |
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Конфигурация CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Конфигурация CommonEncryptionCenc
|
properties.defaultContentKeyPolicyName
|
string
|
ContentKey, который по умолчанию используется текущей потоковой политикой
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Конфигурация EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Конфигурации NoEncryption
|
Ответы
Примеры
Creates a Streaming Policy with clear streaming
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/clearStreamingPolicy?api-version=2022-08-01
{
"properties": {
"noEncryption": {
"enabledProtocols": {
"download": true,
"dash": true,
"hls": true,
"smoothStreaming": true
}
}
}
}
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.NoEncryption;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json
*/
/**
* Sample code: Creates a Streaming Policy with clear streaming.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithClearStreaming(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("clearStreamingPolicy")
.withExistingMediaService("contosorg", "contosomedia")
.withNoEncryption(
new NoEncryption()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(true)
.withDash(true)
.withHls(true)
.withSmoothStreaming(true)))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreateclear.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedClearStreamingPolicy",
parameters={
"properties": {
"noEncryption": {
"enabledProtocols": {"dash": True, "download": True, "hls": True, "smoothStreaming": True}
}
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearStreaming() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedClearStreamingPolicy", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
NoEncryption: &armmediaservices.NoEncryption{
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(true),
Download: to.Ptr(true),
Hls: to.Ptr(true),
SmoothStreaming: to.Ptr(true),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json
*/
async function createsAStreamingPolicyWithClearStreaming() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedClearStreamingPolicy";
const parameters = {
noEncryption: {
enabledProtocols: {
dash: true,
download: true,
hls: true,
smoothStreaming: true,
},
},
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-clear.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedClearStreamingPolicy";
StreamingPolicyData data = new StreamingPolicyData()
{
NoEncryptionEnabledProtocols = new MediaEnabledProtocols(true, true, true, true),
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "clearStreamingPolicy",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/clearStreamingPolicy",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.1535417Z",
"noEncryption": {
"enabledProtocols": {
"download": true,
"dash": true,
"hls": true,
"smoothStreaming": true
}
}
}
}
Creates a Streaming Policy with ClearKey encryption in commonEncryptionCbcs.
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly?api-version=2022-08-01
{
"properties": {
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"commonEncryptionCbcs": {
"enabledProtocols": {
"download": false,
"dash": false,
"hls": true,
"smoothStreaming": false
},
"contentKeys": {
"defaultKey": {
"label": "cbcsDefaultKey"
}
},
"clearKeyEncryptionConfiguration": {
"customKeysAcquisitionUrlTemplate": "https://contoso.com/{AlternativeMediaId}/clearkey/"
}
}
}
}
import com.azure.resourcemanager.mediaservices.models.ClearKeyEncryptionConfiguration;
import com.azure.resourcemanager.mediaservices.models.CommonEncryptionCbcs;
import com.azure.resourcemanager.mediaservices.models.DefaultKey;
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyContentKeys;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json
*/
/**
* Sample code: Creates a Streaming Policy with ClearKey encryption in commonEncryptionCbcs.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCbcs(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly")
.withExistingMediaService("contosorg", "contosomedia")
.withDefaultContentKeyPolicyName("PolicyWithMultipleOptions")
.withCommonEncryptionCbcs(
new CommonEncryptionCbcs()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(false)
.withHls(true)
.withSmoothStreaming(false))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("cbcsDefaultKey")))
.withClearKeyEncryptionConfiguration(
new ClearKeyEncryptionConfiguration()
.withCustomKeysAcquisitionUrlTemplate("fakeTokenPlaceholder")))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreatecommon_encryption_cbcsclear_key_encryption.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly",
parameters={
"properties": {
"commonEncryptionCbcs": {
"clearKeyEncryptionConfiguration": {
"customKeysAcquisitionUrlTemplate": "https://contoso.com/{AlternativeMediaId}/clearkey/"
},
"contentKeys": {"defaultKey": {"label": "cbcsDefaultKey"}},
"enabledProtocols": {"dash": False, "download": False, "hls": True, "smoothStreaming": False},
},
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCbcs() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{
ClearKeyEncryptionConfiguration: &armmediaservices.ClearKeyEncryptionConfiguration{
CustomKeysAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AlternativeMediaId}/clearkey/"),
},
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("cbcsDefaultKey"),
},
},
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(false),
Download: to.Ptr(false),
Hls: to.Ptr(true),
SmoothStreaming: to.Ptr(false),
},
},
DefaultContentKeyPolicyName: to.Ptr("PolicyWithMultipleOptions"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json
*/
async function createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCbcs() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly";
const parameters = {
commonEncryptionCbcs: {
clearKeyEncryptionConfiguration: {
customKeysAcquisitionUrlTemplate: "https://contoso.com/{AlternativeMediaId}/clearkey/",
},
contentKeys: { defaultKey: { label: "cbcsDefaultKey" } },
enabledProtocols: {
dash: false,
download: false,
hls: true,
smoothStreaming: false,
},
},
defaultContentKeyPolicyName: "PolicyWithMultipleOptions",
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-clearKeyEncryption.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly";
StreamingPolicyData data = new StreamingPolicyData()
{
DefaultContentKeyPolicyName = "PolicyWithMultipleOptions",
CommonEncryptionCbcs = new CommonEncryptionCbcs()
{
EnabledProtocols = new MediaEnabledProtocols(false, false, true, false),
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "cbcsDefaultKey",
},
},
ClearKeyEncryptionCustomKeysAcquisitionUriTemplate = "https://contoso.com/{AlternativeMediaId}/clearkey/",
},
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.6197199Z",
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"commonEncryptionCbcs": {
"enabledProtocols": {
"download": false,
"dash": false,
"hls": true,
"smoothStreaming": false
},
"clearTracks": [],
"contentKeys": {
"defaultKey": {
"label": "cbcsDefaultKey"
},
"keyToTrackMappings": []
},
"clearKeyEncryptionConfiguration": {
"customKeysAcquisitionUrlTemplate": "https://contoso.com/{AlternativeMediaId}/clearkey/"
}
}
}
}
Creates a Streaming Policy with ClearKey encryption in commonEncryptionCenc.
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly?api-version=2022-08-01
{
"properties": {
"defaultContentKeyPolicyName": "PolicyWithPlayReadyOptionAndOpenRestriction",
"commonEncryptionCenc": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": false,
"smoothStreaming": true
},
"clearTracks": [
{
"trackSelections": [
{
"property": "FourCC",
"operation": "Equal",
"value": "hev1"
}
]
}
],
"contentKeys": {
"defaultKey": {
"label": "cencDefaultKey"
}
},
"clearKeyEncryptionConfiguration": {
"customKeysAcquisitionUrlTemplate": "https://contoso.com/{AlternativeMediaId}/clearkey/"
}
}
}
}
import com.azure.resourcemanager.mediaservices.models.ClearKeyEncryptionConfiguration;
import com.azure.resourcemanager.mediaservices.models.CommonEncryptionCenc;
import com.azure.resourcemanager.mediaservices.models.DefaultKey;
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyContentKeys;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyCompareOperation;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyCondition;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyType;
import com.azure.resourcemanager.mediaservices.models.TrackSelection;
import java.util.Arrays;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json
*/
/**
* Sample code: Creates a Streaming Policy with ClearKey encryption in commonEncryptionCenc.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCenc(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly")
.withExistingMediaService("contosorg", "contosomedia")
.withDefaultContentKeyPolicyName("PolicyWithPlayReadyOptionAndOpenRestriction")
.withCommonEncryptionCenc(
new CommonEncryptionCenc()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(true)
.withHls(false)
.withSmoothStreaming(true))
.withClearTracks(
Arrays
.asList(
new TrackSelection()
.withTrackSelections(
Arrays
.asList(
new TrackPropertyCondition()
.withProperty(TrackPropertyType.FOUR_CC)
.withOperation(TrackPropertyCompareOperation.EQUAL)
.withValue("hev1")))))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("cencDefaultKey")))
.withClearKeyEncryptionConfiguration(
new ClearKeyEncryptionConfiguration()
.withCustomKeysAcquisitionUrlTemplate("fakeTokenPlaceholder")))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreatecommon_encryption_cencclear_key_encryption.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly",
parameters={
"properties": {
"commonEncryptionCenc": {
"clearKeyEncryptionConfiguration": {
"customKeysAcquisitionUrlTemplate": "https://contoso.com/{AlternativeMediaId}/clearkey/"
},
"clearTracks": [
{"trackSelections": [{"operation": "Equal", "property": "FourCC", "value": "hev1"}]}
],
"contentKeys": {"defaultKey": {"label": "cencDefaultKey"}},
"enabledProtocols": {"dash": True, "download": False, "hls": False, "smoothStreaming": True},
},
"defaultContentKeyPolicyName": "PolicyWithPlayReadyOptionAndOpenRestriction",
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCenc() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{
ClearKeyEncryptionConfiguration: &armmediaservices.ClearKeyEncryptionConfiguration{
CustomKeysAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AlternativeMediaId}/clearkey/"),
},
ClearTracks: []*armmediaservices.TrackSelection{
{
TrackSelections: []*armmediaservices.TrackPropertyCondition{
{
Operation: to.Ptr(armmediaservices.TrackPropertyCompareOperationEqual),
Property: to.Ptr(armmediaservices.TrackPropertyTypeFourCC),
Value: to.Ptr("hev1"),
}},
}},
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("cencDefaultKey"),
},
},
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(true),
Download: to.Ptr(false),
Hls: to.Ptr(false),
SmoothStreaming: to.Ptr(true),
},
},
DefaultContentKeyPolicyName: to.Ptr("PolicyWithPlayReadyOptionAndOpenRestriction"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json
*/
async function createsAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCenc() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly";
const parameters = {
commonEncryptionCenc: {
clearKeyEncryptionConfiguration: {
customKeysAcquisitionUrlTemplate: "https://contoso.com/{AlternativeMediaId}/clearkey/",
},
clearTracks: [
{
trackSelections: [{ operation: "Equal", property: "FourCC", value: "hev1" }],
},
],
contentKeys: { defaultKey: { label: "cencDefaultKey" } },
enabledProtocols: {
dash: true,
download: false,
hls: false,
smoothStreaming: true,
},
},
defaultContentKeyPolicyName: "PolicyWithPlayReadyOptionAndOpenRestriction",
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-clearKeyEncryption.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly";
StreamingPolicyData data = new StreamingPolicyData()
{
DefaultContentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction",
CommonEncryptionCenc = new CommonEncryptionCenc()
{
EnabledProtocols = new MediaEnabledProtocols(false, true, false, true),
ClearTracks =
{
new MediaTrackSelection()
{
TrackSelections =
{
new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal)
{
Value = "hev1",
}
},
}
},
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "cencDefaultKey",
},
},
ClearKeyEncryptionCustomKeysAcquisitionUriTemplate = "https://contoso.com/{AlternativeMediaId}/clearkey/",
},
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.4678543Z",
"defaultContentKeyPolicyName": "PolicyWithPlayReadyOptionAndOpenRestriction",
"commonEncryptionCenc": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": false,
"smoothStreaming": true
},
"clearTracks": [
{
"trackSelections": [
{
"property": "FourCC",
"operation": "Equal",
"value": "hev1"
}
]
}
],
"contentKeys": {
"defaultKey": {
"label": "cencDefaultKey"
},
"keyToTrackMappings": []
},
"clearKeyEncryptionConfiguration": {
"customKeysAcquisitionUrlTemplate": "https://contoso.com/{AlternativeMediaId}/clearkey/"
}
}
}
}
Creates a Streaming Policy with commonEncryptionCbcs only
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly?api-version=2022-08-01
{
"properties": {
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"commonEncryptionCbcs": {
"enabledProtocols": {
"download": false,
"dash": false,
"hls": true,
"smoothStreaming": false
},
"contentKeys": {
"defaultKey": {
"label": "cbcsDefaultKey"
}
},
"drm": {
"fairPlay": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
"allowPersistentLicense": true
}
}
}
}
}
import com.azure.resourcemanager.mediaservices.models.CbcsDrmConfiguration;
import com.azure.resourcemanager.mediaservices.models.CommonEncryptionCbcs;
import com.azure.resourcemanager.mediaservices.models.DefaultKey;
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyContentKeys;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyFairPlayConfiguration;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json
*/
/**
* Sample code: Creates a Streaming Policy with commonEncryptionCbcs only.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithCommonEncryptionCbcsOnly(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly")
.withExistingMediaService("contosorg", "contosomedia")
.withDefaultContentKeyPolicyName("PolicyWithMultipleOptions")
.withCommonEncryptionCbcs(
new CommonEncryptionCbcs()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(false)
.withHls(true)
.withSmoothStreaming(false))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("cbcsDefaultKey")))
.withDrm(
new CbcsDrmConfiguration()
.withFairPlay(
new StreamingPolicyFairPlayConfiguration()
.withCustomLicenseAcquisitionUrlTemplate(
"https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}")
.withAllowPersistentLicense(true))))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreatecommon_encryption_cbcsonly.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly",
parameters={
"properties": {
"commonEncryptionCbcs": {
"contentKeys": {"defaultKey": {"label": "cbcsDefaultKey"}},
"drm": {
"fairPlay": {
"allowPersistentLicense": True,
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
}
},
"enabledProtocols": {"dash": False, "download": False, "hls": True, "smoothStreaming": False},
},
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithCommonEncryptionCbcsOnly() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("cbcsDefaultKey"),
},
},
Drm: &armmediaservices.CbcsDrmConfiguration{
FairPlay: &armmediaservices.StreamingPolicyFairPlayConfiguration{
AllowPersistentLicense: to.Ptr(true),
CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}"),
},
},
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(false),
Download: to.Ptr(false),
Hls: to.Ptr(true),
SmoothStreaming: to.Ptr(false),
},
},
DefaultContentKeyPolicyName: to.Ptr("PolicyWithMultipleOptions"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json
*/
async function createsAStreamingPolicyWithCommonEncryptionCbcsOnly() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly";
const parameters = {
commonEncryptionCbcs: {
contentKeys: { defaultKey: { label: "cbcsDefaultKey" } },
drm: {
fairPlay: {
allowPersistentLicense: true,
customLicenseAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
},
},
enabledProtocols: {
dash: false,
download: false,
hls: true,
smoothStreaming: false,
},
},
defaultContentKeyPolicyName: "PolicyWithMultipleOptions",
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCbcs-only.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly";
StreamingPolicyData data = new StreamingPolicyData()
{
DefaultContentKeyPolicyName = "PolicyWithMultipleOptions",
CommonEncryptionCbcs = new CommonEncryptionCbcs()
{
EnabledProtocols = new MediaEnabledProtocols(false, false, true, false),
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "cbcsDefaultKey",
},
},
Drm = new CbcsDrmConfiguration()
{
FairPlay = new StreamingPolicyFairPlayConfiguration(true)
{
CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
},
},
},
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.6197199Z",
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"commonEncryptionCbcs": {
"enabledProtocols": {
"download": false,
"dash": false,
"hls": true,
"smoothStreaming": false
},
"clearTracks": [],
"contentKeys": {
"defaultKey": {
"label": "cbcsDefaultKey"
},
"keyToTrackMappings": []
},
"drm": {
"fairPlay": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
"allowPersistentLicense": true
}
}
}
}
}
Creates a Streaming Policy with commonEncryptionCenc only
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly?api-version=2022-08-01
{
"properties": {
"defaultContentKeyPolicyName": "PolicyWithPlayReadyOptionAndOpenRestriction",
"commonEncryptionCenc": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": false,
"smoothStreaming": true
},
"clearTracks": [
{
"trackSelections": [
{
"property": "FourCC",
"operation": "Equal",
"value": "hev1"
}
]
}
],
"contentKeys": {
"defaultKey": {
"label": "cencDefaultKey"
}
},
"drm": {
"playReady": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
"playReadyCustomAttributes": "PlayReady CustomAttributes"
},
"widevine": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"
}
}
}
}
}
import com.azure.resourcemanager.mediaservices.models.CencDrmConfiguration;
import com.azure.resourcemanager.mediaservices.models.CommonEncryptionCenc;
import com.azure.resourcemanager.mediaservices.models.DefaultKey;
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyContentKeys;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyPlayReadyConfiguration;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyWidevineConfiguration;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyCompareOperation;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyCondition;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyType;
import com.azure.resourcemanager.mediaservices.models.TrackSelection;
import java.util.Arrays;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json
*/
/**
* Sample code: Creates a Streaming Policy with commonEncryptionCenc only.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithCommonEncryptionCencOnly(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly")
.withExistingMediaService("contosorg", "contosomedia")
.withDefaultContentKeyPolicyName("PolicyWithPlayReadyOptionAndOpenRestriction")
.withCommonEncryptionCenc(
new CommonEncryptionCenc()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(true)
.withHls(false)
.withSmoothStreaming(true))
.withClearTracks(
Arrays
.asList(
new TrackSelection()
.withTrackSelections(
Arrays
.asList(
new TrackPropertyCondition()
.withProperty(TrackPropertyType.FOUR_CC)
.withOperation(TrackPropertyCompareOperation.EQUAL)
.withValue("hev1")))))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("cencDefaultKey")))
.withDrm(
new CencDrmConfiguration()
.withPlayReady(
new StreamingPolicyPlayReadyConfiguration()
.withCustomLicenseAcquisitionUrlTemplate(
"https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}")
.withPlayReadyCustomAttributes("PlayReady CustomAttributes"))
.withWidevine(
new StreamingPolicyWidevineConfiguration()
.withCustomLicenseAcquisitionUrlTemplate(
"https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"))))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreatecommon_encryption_cenconly.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly",
parameters={
"properties": {
"commonEncryptionCenc": {
"clearTracks": [
{"trackSelections": [{"operation": "Equal", "property": "FourCC", "value": "hev1"}]}
],
"contentKeys": {"defaultKey": {"label": "cencDefaultKey"}},
"drm": {
"playReady": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
"playReadyCustomAttributes": "PlayReady CustomAttributes",
},
"widevine": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"
},
},
"enabledProtocols": {"dash": True, "download": False, "hls": False, "smoothStreaming": True},
},
"defaultContentKeyPolicyName": "PolicyWithPlayReadyOptionAndOpenRestriction",
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithCommonEncryptionCencOnly() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{
ClearTracks: []*armmediaservices.TrackSelection{
{
TrackSelections: []*armmediaservices.TrackPropertyCondition{
{
Operation: to.Ptr(armmediaservices.TrackPropertyCompareOperationEqual),
Property: to.Ptr(armmediaservices.TrackPropertyTypeFourCC),
Value: to.Ptr("hev1"),
}},
}},
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("cencDefaultKey"),
},
},
Drm: &armmediaservices.CencDrmConfiguration{
PlayReady: &armmediaservices.StreamingPolicyPlayReadyConfiguration{
CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}"),
PlayReadyCustomAttributes: to.Ptr("PlayReady CustomAttributes"),
},
Widevine: &armmediaservices.StreamingPolicyWidevineConfiguration{
CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"),
},
},
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(true),
Download: to.Ptr(false),
Hls: to.Ptr(false),
SmoothStreaming: to.Ptr(true),
},
},
DefaultContentKeyPolicyName: to.Ptr("PolicyWithPlayReadyOptionAndOpenRestriction"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json
*/
async function createsAStreamingPolicyWithCommonEncryptionCencOnly() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly";
const parameters = {
commonEncryptionCenc: {
clearTracks: [
{
trackSelections: [{ operation: "Equal", property: "FourCC", value: "hev1" }],
},
],
contentKeys: { defaultKey: { label: "cencDefaultKey" } },
drm: {
playReady: {
customLicenseAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
playReadyCustomAttributes: "PlayReady CustomAttributes",
},
widevine: {
customLicenseAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId",
},
},
enabledProtocols: {
dash: true,
download: false,
hls: false,
smoothStreaming: true,
},
},
defaultContentKeyPolicyName: "PolicyWithPlayReadyOptionAndOpenRestriction",
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-commonEncryptionCenc-only.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly";
StreamingPolicyData data = new StreamingPolicyData()
{
DefaultContentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction",
CommonEncryptionCenc = new CommonEncryptionCenc()
{
EnabledProtocols = new MediaEnabledProtocols(false, true, false, true),
ClearTracks =
{
new MediaTrackSelection()
{
TrackSelections =
{
new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal)
{
Value = "hev1",
}
},
}
},
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "cencDefaultKey",
},
},
Drm = new CencDrmConfiguration()
{
PlayReady = new StreamingPolicyPlayReadyConfiguration()
{
CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
PlayReadyCustomAttributes = "PlayReady CustomAttributes",
},
WidevineCustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId",
},
},
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.4678543Z",
"defaultContentKeyPolicyName": "PolicyWithPlayReadyOptionAndOpenRestriction",
"commonEncryptionCenc": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": false,
"smoothStreaming": true
},
"clearTracks": [
{
"trackSelections": [
{
"property": "FourCC",
"operation": "Equal",
"value": "hev1"
}
]
}
],
"contentKeys": {
"defaultKey": {
"label": "cencDefaultKey"
},
"keyToTrackMappings": []
},
"drm": {
"playReady": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
"playReadyCustomAttributes": "PlayReady CustomAttributes"
},
"widevine": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId}"
}
}
}
}
}
Creates a Streaming Policy with envelopeEncryption only
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly?api-version=2022-08-01
{
"properties": {
"defaultContentKeyPolicyName": "PolicyWithClearKeyOptionAndTokenRestriction",
"envelopeEncryption": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": true,
"smoothStreaming": true
},
"contentKeys": {
"defaultKey": {
"label": "aesDefaultKey"
}
},
"customKeyAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"
}
}
}
import com.azure.resourcemanager.mediaservices.models.DefaultKey;
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.EnvelopeEncryption;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyContentKeys;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json
*/
/**
* Sample code: Creates a Streaming Policy with envelopeEncryption only.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithEnvelopeEncryptionOnly(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly")
.withExistingMediaService("contosorg", "contosomedia")
.withDefaultContentKeyPolicyName("PolicyWithClearKeyOptionAndTokenRestriction")
.withEnvelopeEncryption(
new EnvelopeEncryption()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(true)
.withHls(true)
.withSmoothStreaming(true))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("aesDefaultKey")))
.withCustomKeyAcquisitionUrlTemplate("fakeTokenPlaceholder"))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreateenvelope_encryptiononly.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly",
parameters={
"properties": {
"defaultContentKeyPolicyName": "PolicyWithClearKeyOptionAndTokenRestriction",
"envelopeEncryption": {
"contentKeys": {"defaultKey": {"label": "aesDefaultKey"}},
"customKeyAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}",
"enabledProtocols": {"dash": True, "download": False, "hls": True, "smoothStreaming": True},
},
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithEnvelopeEncryptionOnly() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
DefaultContentKeyPolicyName: to.Ptr("PolicyWithClearKeyOptionAndTokenRestriction"),
EnvelopeEncryption: &armmediaservices.EnvelopeEncryption{
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("aesDefaultKey"),
},
},
CustomKeyAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"),
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(true),
Download: to.Ptr(false),
Hls: to.Ptr(true),
SmoothStreaming: to.Ptr(true),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json
*/
async function createsAStreamingPolicyWithEnvelopeEncryptionOnly() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly";
const parameters = {
defaultContentKeyPolicyName: "PolicyWithClearKeyOptionAndTokenRestriction",
envelopeEncryption: {
contentKeys: { defaultKey: { label: "aesDefaultKey" } },
customKeyAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}",
enabledProtocols: {
dash: true,
download: false,
hls: true,
smoothStreaming: true,
},
},
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-envelopeEncryption-only.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly";
StreamingPolicyData data = new StreamingPolicyData()
{
DefaultContentKeyPolicyName = "PolicyWithClearKeyOptionAndTokenRestriction",
EnvelopeEncryption = new EnvelopeEncryption()
{
EnabledProtocols = new MediaEnabledProtocols(false, true, true, true),
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "aesDefaultKey",
},
},
CustomKeyAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}",
},
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.3055712Z",
"defaultContentKeyPolicyName": "PolicyWithClearKeyOptionAndTokenRestriction",
"envelopeEncryption": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": true,
"smoothStreaming": true
},
"clearTracks": [],
"contentKeys": {
"defaultKey": {
"label": "aesDefaultKey"
},
"keyToTrackMappings": []
},
"customKeyAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"
}
}
}
Creates a Streaming Policy with secure streaming
Образец запроса
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicy?api-version=2022-08-01
{
"properties": {
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"envelopeEncryption": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": true,
"smoothStreaming": true
},
"contentKeys": {
"defaultKey": {
"label": "aesDefaultKey"
}
},
"customKeyAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"
},
"commonEncryptionCenc": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": false,
"smoothStreaming": true
},
"clearTracks": [
{
"trackSelections": [
{
"property": "FourCC",
"operation": "Equal",
"value": "hev1"
}
]
}
],
"contentKeys": {
"defaultKey": {
"label": "cencDefaultKey"
}
},
"drm": {
"playReady": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
"playReadyCustomAttributes": "PlayReady CustomAttributes"
},
"widevine": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"
}
}
},
"commonEncryptionCbcs": {
"enabledProtocols": {
"download": false,
"dash": false,
"hls": true,
"smoothStreaming": false
},
"contentKeys": {
"defaultKey": {
"label": "cbcsDefaultKey"
}
},
"drm": {
"fairPlay": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
"allowPersistentLicense": true
}
}
}
}
}
import com.azure.resourcemanager.mediaservices.models.CbcsDrmConfiguration;
import com.azure.resourcemanager.mediaservices.models.CencDrmConfiguration;
import com.azure.resourcemanager.mediaservices.models.CommonEncryptionCbcs;
import com.azure.resourcemanager.mediaservices.models.CommonEncryptionCenc;
import com.azure.resourcemanager.mediaservices.models.DefaultKey;
import com.azure.resourcemanager.mediaservices.models.EnabledProtocols;
import com.azure.resourcemanager.mediaservices.models.EnvelopeEncryption;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyContentKeys;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyFairPlayConfiguration;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyPlayReadyConfiguration;
import com.azure.resourcemanager.mediaservices.models.StreamingPolicyWidevineConfiguration;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyCompareOperation;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyCondition;
import com.azure.resourcemanager.mediaservices.models.TrackPropertyType;
import com.azure.resourcemanager.mediaservices.models.TrackSelection;
import java.util.Arrays;
/** Samples for StreamingPolicies Create. */
public final class Main {
/*
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json
*/
/**
* Sample code: Creates a Streaming Policy with secure streaming.
*
* @param manager Entry point to MediaServicesManager.
*/
public static void createsAStreamingPolicyWithSecureStreaming(
com.azure.resourcemanager.mediaservices.MediaServicesManager manager) {
manager
.streamingPolicies()
.define("UserCreatedSecureStreamingPolicy")
.withExistingMediaService("contosorg", "contosomedia")
.withDefaultContentKeyPolicyName("PolicyWithMultipleOptions")
.withEnvelopeEncryption(
new EnvelopeEncryption()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(true)
.withHls(true)
.withSmoothStreaming(true))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("aesDefaultKey")))
.withCustomKeyAcquisitionUrlTemplate("fakeTokenPlaceholder"))
.withCommonEncryptionCenc(
new CommonEncryptionCenc()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(true)
.withHls(false)
.withSmoothStreaming(true))
.withClearTracks(
Arrays
.asList(
new TrackSelection()
.withTrackSelections(
Arrays
.asList(
new TrackPropertyCondition()
.withProperty(TrackPropertyType.FOUR_CC)
.withOperation(TrackPropertyCompareOperation.EQUAL)
.withValue("hev1")))))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("cencDefaultKey")))
.withDrm(
new CencDrmConfiguration()
.withPlayReady(
new StreamingPolicyPlayReadyConfiguration()
.withCustomLicenseAcquisitionUrlTemplate(
"https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}")
.withPlayReadyCustomAttributes("PlayReady CustomAttributes"))
.withWidevine(
new StreamingPolicyWidevineConfiguration()
.withCustomLicenseAcquisitionUrlTemplate(
"https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"))))
.withCommonEncryptionCbcs(
new CommonEncryptionCbcs()
.withEnabledProtocols(
new EnabledProtocols()
.withDownload(false)
.withDash(false)
.withHls(true)
.withSmoothStreaming(false))
.withContentKeys(
new StreamingPolicyContentKeys().withDefaultKey(new DefaultKey().withLabel("cbcsDefaultKey")))
.withDrm(
new CbcsDrmConfiguration()
.withFairPlay(
new StreamingPolicyFairPlayConfiguration()
.withCustomLicenseAcquisitionUrlTemplate(
"https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}")
.withAllowPersistentLicense(true))))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.media import AzureMediaServices
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-media
# USAGE
python streamingpoliciescreatesecurestreaming.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AzureMediaServices(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.streaming_policies.create(
resource_group_name="contoso",
account_name="contosomedia",
streaming_policy_name="UserCreatedSecureStreamingPolicy",
parameters={
"properties": {
"commonEncryptionCbcs": {
"contentKeys": {"defaultKey": {"label": "cbcsDefaultKey"}},
"drm": {
"fairPlay": {
"allowPersistentLicense": True,
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
}
},
"enabledProtocols": {"dash": False, "download": False, "hls": True, "smoothStreaming": False},
},
"commonEncryptionCenc": {
"clearTracks": [
{"trackSelections": [{"operation": "Equal", "property": "FourCC", "value": "hev1"}]}
],
"contentKeys": {"defaultKey": {"label": "cencDefaultKey"}},
"drm": {
"playReady": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
"playReadyCustomAttributes": "PlayReady CustomAttributes",
},
"widevine": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"
},
},
"enabledProtocols": {"dash": True, "download": False, "hls": False, "smoothStreaming": True},
},
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"envelopeEncryption": {
"contentKeys": {"defaultKey": {"label": "aesDefaultKey"}},
"customKeyAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}",
"enabledProtocols": {"dash": True, "download": False, "hls": True, "smoothStreaming": True},
},
}
},
)
print(response)
# x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmediaservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mediaservices/armmediaservices/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json
func ExampleStreamingPoliciesClient_Create_createsAStreamingPolicyWithSecureStreaming() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmediaservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewStreamingPoliciesClient().Create(ctx, "contoso", "contosomedia", "UserCreatedSecureStreamingPolicy", armmediaservices.StreamingPolicy{
Properties: &armmediaservices.StreamingPolicyProperties{
CommonEncryptionCbcs: &armmediaservices.CommonEncryptionCbcs{
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("cbcsDefaultKey"),
},
},
Drm: &armmediaservices.CbcsDrmConfiguration{
FairPlay: &armmediaservices.StreamingPolicyFairPlayConfiguration{
AllowPersistentLicense: to.Ptr(true),
CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}"),
},
},
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(false),
Download: to.Ptr(false),
Hls: to.Ptr(true),
SmoothStreaming: to.Ptr(false),
},
},
CommonEncryptionCenc: &armmediaservices.CommonEncryptionCenc{
ClearTracks: []*armmediaservices.TrackSelection{
{
TrackSelections: []*armmediaservices.TrackPropertyCondition{
{
Operation: to.Ptr(armmediaservices.TrackPropertyCompareOperationEqual),
Property: to.Ptr(armmediaservices.TrackPropertyTypeFourCC),
Value: to.Ptr("hev1"),
}},
}},
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("cencDefaultKey"),
},
},
Drm: &armmediaservices.CencDrmConfiguration{
PlayReady: &armmediaservices.StreamingPolicyPlayReadyConfiguration{
CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}"),
PlayReadyCustomAttributes: to.Ptr("PlayReady CustomAttributes"),
},
Widevine: &armmediaservices.StreamingPolicyWidevineConfiguration{
CustomLicenseAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"),
},
},
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(true),
Download: to.Ptr(false),
Hls: to.Ptr(false),
SmoothStreaming: to.Ptr(true),
},
},
DefaultContentKeyPolicyName: to.Ptr("PolicyWithMultipleOptions"),
EnvelopeEncryption: &armmediaservices.EnvelopeEncryption{
ContentKeys: &armmediaservices.StreamingPolicyContentKeys{
DefaultKey: &armmediaservices.DefaultKey{
Label: to.Ptr("aesDefaultKey"),
},
},
CustomKeyAcquisitionURLTemplate: to.Ptr("https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"),
EnabledProtocols: &armmediaservices.EnabledProtocols{
Dash: to.Ptr(true),
Download: to.Ptr(false),
Hls: to.Ptr(true),
SmoothStreaming: to.Ptr(true),
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMediaServices } = require("@azure/arm-mediaservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a Streaming Policy in the Media Services account
*
* @summary Create a Streaming Policy in the Media Services account
* x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json
*/
async function createsAStreamingPolicyWithSecureStreaming() {
const subscriptionId =
process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso";
const accountName = "contosomedia";
const streamingPolicyName = "UserCreatedSecureStreamingPolicy";
const parameters = {
commonEncryptionCbcs: {
contentKeys: { defaultKey: { label: "cbcsDefaultKey" } },
drm: {
fairPlay: {
allowPersistentLicense: true,
customLicenseAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
},
},
enabledProtocols: {
dash: false,
download: false,
hls: true,
smoothStreaming: false,
},
},
commonEncryptionCenc: {
clearTracks: [
{
trackSelections: [{ operation: "Equal", property: "FourCC", value: "hev1" }],
},
],
contentKeys: { defaultKey: { label: "cencDefaultKey" } },
drm: {
playReady: {
customLicenseAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
playReadyCustomAttributes: "PlayReady CustomAttributes",
},
widevine: {
customLicenseAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId",
},
},
enabledProtocols: {
dash: true,
download: false,
hls: false,
smoothStreaming: true,
},
},
defaultContentKeyPolicyName: "PolicyWithMultipleOptions",
envelopeEncryption: {
contentKeys: { defaultKey: { label: "aesDefaultKey" } },
customKeyAcquisitionUrlTemplate:
"https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}",
enabledProtocols: {
dash: true,
download: false,
hls: true,
smoothStreaming: true,
},
},
};
const credential = new DefaultAzureCredential();
const client = new AzureMediaServices(credential, subscriptionId);
const result = await client.streamingPolicies.create(
resourceGroupName,
accountName,
streamingPolicyName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Media;
using Azure.ResourceManager.Media.Models;
// Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/streaming-policies-create-secure-streaming.json
// this example is just showing the usage of "StreamingPolicies_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this MediaServicesAccountResource created on azure
// for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "contoso";
string accountName = "contosomedia";
ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId);
// get the collection of this StreamingPolicyResource
StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies();
// invoke the operation
string streamingPolicyName = "UserCreatedSecureStreamingPolicy";
StreamingPolicyData data = new StreamingPolicyData()
{
DefaultContentKeyPolicyName = "PolicyWithMultipleOptions",
EnvelopeEncryption = new EnvelopeEncryption()
{
EnabledProtocols = new MediaEnabledProtocols(false, true, true, true),
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "aesDefaultKey",
},
},
CustomKeyAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}",
},
CommonEncryptionCenc = new CommonEncryptionCenc()
{
EnabledProtocols = new MediaEnabledProtocols(false, true, false, true),
ClearTracks =
{
new MediaTrackSelection()
{
TrackSelections =
{
new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal)
{
Value = "hev1",
}
},
}
},
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "cencDefaultKey",
},
},
Drm = new CencDrmConfiguration()
{
PlayReady = new StreamingPolicyPlayReadyConfiguration()
{
CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
PlayReadyCustomAttributes = "PlayReady CustomAttributes",
},
WidevineCustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId",
},
},
CommonEncryptionCbcs = new CommonEncryptionCbcs()
{
EnabledProtocols = new MediaEnabledProtocols(false, false, true, false),
ContentKeys = new StreamingPolicyContentKeys()
{
DefaultKey = new EncryptionSchemeDefaultKey()
{
Label = "cbcsDefaultKey",
},
},
Drm = new CbcsDrmConfiguration()
{
FairPlay = new StreamingPolicyFairPlayConfiguration(true)
{
CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
},
},
},
};
ArmOperation<StreamingPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingPolicyName, data);
StreamingPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
StreamingPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"name": "UserCreatedSecureStreamingPolicy",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/streamingPolicies/UserCreatedSecureStreamingPolicy",
"type": "Microsoft.Media/mediaservices/streamingPolicies",
"properties": {
"created": "2018-08-08T18:29:31.7715696Z",
"defaultContentKeyPolicyName": "PolicyWithMultipleOptions",
"envelopeEncryption": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": true,
"smoothStreaming": true
},
"clearTracks": [],
"contentKeys": {
"defaultKey": {
"label": "aesDefaultKey"
},
"keyToTrackMappings": []
},
"customKeyAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}"
},
"commonEncryptionCenc": {
"enabledProtocols": {
"download": false,
"dash": true,
"hls": false,
"smoothStreaming": true
},
"clearTracks": [
{
"trackSelections": [
{
"property": "FourCC",
"operation": "Equal",
"value": "hev1"
}
]
}
],
"contentKeys": {
"defaultKey": {
"label": "cencDefaultKey"
},
"keyToTrackMappings": []
},
"drm": {
"playReady": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}",
"playReadyCustomAttributes": "PlayReady CustomAttributes"
},
"widevine": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId"
}
}
},
"commonEncryptionCbcs": {
"enabledProtocols": {
"download": false,
"dash": false,
"hls": true,
"smoothStreaming": false
},
"clearTracks": [],
"contentKeys": {
"defaultKey": {
"label": "cbcsDefaultKey"
},
"keyToTrackMappings": []
},
"drm": {
"fairPlay": {
"customLicenseAcquisitionUrlTemplate": "https://contoso.com/{AssetAlternativeId}/fairplay/{ContentKeyId}",
"allowPersistentLicense": true
}
}
}
}
}
Определения
CbcsDrmConfiguration
Класс для указания конфигураций DRM схемы CommonEncryptionCbcs в политике потоковой передачи
CencDrmConfiguration
Класс для указания конфигураций DRM схемы CommonEncryptionCenc в политике потоковой передачи
ClearKeyEncryptionConfiguration
Класс для указания конфигурации ClearKey общих схем шифрования в политике потоковой передачи
Имя |
Тип |
Описание |
customKeysAcquisitionUrlTemplate
|
string
|
Шаблон для URL-адреса пользовательской службы, предоставляющей ключи содержимого игрокам конечных пользователей. Не требуется при использовании Служб мультимедиа Azure для выдачи лицензий. Этот шаблон поддерживает заменяемые маркеры, которые служба будет обновлять во время выполнения, устанавливая значение, соответствующее запросу. Поддерживаемое в настоящее время значение маркера — {AlternativeMediaId}, которое заменяется значением StreamingLocatorId.AlternativeMediaId.
|
CommonEncryptionCbcs
Класс для схемы шифрования CommonEncryptionCbcs
Имя |
Тип |
Описание |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Необязательная конфигурация, поддерживающая ClearKey в схеме шифрования CommonEncryptionCbcs.
|
clearTracks
|
TrackSelection[]
|
Представление дорожек, которые не следует шифровать
|
contentKeys
|
StreamingPolicyContentKeys
|
Представление ключа содержимого по умолчанию для каждой схемы шифрования и отдельных ключей содержимого для определенных дорожек
|
drm
|
CbcsDrmConfiguration
|
Настройка DRM для текущей схемы шифрования
|
enabledProtocols
|
EnabledProtocols
|
Представление поддерживаемых протоколов
|
CommonEncryptionCenc
Класс для схемы шифрования конвертов
Имя |
Тип |
Описание |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Необязательная конфигурация, поддерживающая ClearKey в схеме шифрования CommonEncryptionCenc.
|
clearTracks
|
TrackSelection[]
|
Представление дорожек, которые не следует шифровать
|
contentKeys
|
StreamingPolicyContentKeys
|
Представление ключа содержимого по умолчанию для каждой схемы шифрования и отдельных ключей содержимого для определенных дорожек
|
drm
|
CencDrmConfiguration
|
Настройка DRM для схемы шифрования CommonEncryptionCenc
|
enabledProtocols
|
EnabledProtocols
|
Представление поддерживаемых протоколов
|
createdByType
Тип удостоверения, создавшего ресурс.
Имя |
Тип |
Описание |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DefaultKey
Класс для указания свойств ключа содержимого по умолчанию для каждой схемы шифрования
Имя |
Тип |
Описание |
label
|
string
|
Метка может использоваться для указания ключа содержимого при создании указателя потоковой передачи
|
policyName
|
string
|
Политика, используемая ключом по умолчанию
|
EnabledProtocols
Класс для указания включенных протоколов
Имя |
Тип |
Описание |
dash
|
boolean
|
Включить протокол DASH или нет
|
download
|
boolean
|
Включить протокол скачивания или нет
|
hls
|
boolean
|
Включение протокола HLS
|
smoothStreaming
|
boolean
|
Включить протокол SmoothStreaming или нет
|
EnvelopeEncryption
Класс для схемы шифрования EnvelopeEncryption
Имя |
Тип |
Описание |
clearTracks
|
TrackSelection[]
|
Представление дорожек, которые не следует шифровать
|
contentKeys
|
StreamingPolicyContentKeys
|
Представление ключа содержимого по умолчанию для каждой схемы шифрования и отдельных ключей содержимого для определенных дорожек
|
customKeyAcquisitionUrlTemplate
|
string
|
Шаблон ДЛЯ URL-адреса пользовательской службы, предоставляющей ключи игрокам конечных пользователей. Не требуется при использовании Служб мультимедиа Azure для выдачи ключей. Этот шаблон поддерживает заменяемые маркеры, которые служба будет обновлять во время выполнения, устанавливая значение, соответствующее запросу. В настоящее время поддерживаются значения маркера {AlternativeMediaId}, который заменяется значением StreamingLocatorId.AlternativeMediaId и {ContentKeyId}, который заменяется значением идентификатора запрашиваемого ключа.
|
enabledProtocols
|
EnabledProtocols
|
Представление поддерживаемых протоколов
|
ErrorAdditionalInfo
Дополнительные сведения об ошибке управления ресурсами.
Имя |
Тип |
Описание |
info
|
object
|
Дополнительные сведения.
|
type
|
string
|
Тип дополнительных сведений.
|
ErrorDetail
Сведения об ошибке.
Имя |
Тип |
Описание |
additionalInfo
|
ErrorAdditionalInfo[]
|
Дополнительные сведения об ошибке.
|
code
|
string
|
Код ошибки.
|
details
|
ErrorDetail[]
|
Сведения об ошибке.
|
message
|
string
|
Сообщение об ошибке.
|
target
|
string
|
Целевой объект ошибки.
|
ErrorResponse
Сообщение об ошибке
NoEncryption
Класс для схемы NoEncryption
Имя |
Тип |
Описание |
enabledProtocols
|
EnabledProtocols
|
Представление поддерживаемых протоколов
|
StreamingPolicy
Ресурс политики потоковой передачи
Имя |
Тип |
Описание |
id
|
string
|
Полный идентификатор ресурса. Пример : /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
Имя ресурса.
|
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Конфигурация CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Конфигурация CommonEncryptionCenc
|
properties.created
|
string
|
Время создания политики потоковой передачи
|
properties.defaultContentKeyPolicyName
|
string
|
ContentKey, который по умолчанию используется текущей потоковой политикой
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Конфигурация EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Конфигурации NoEncryption
|
systemData
|
systemData
|
Системные метаданные, относящиеся к этому ресурсу.
|
type
|
string
|
Тип ресурса. Например, "Microsoft.Compute/virtualMachines" или "Microsoft.Storage/storageAccounts"
|
StreamingPolicyContentKey
Класс для указания свойств ключа содержимого
Имя |
Тип |
Описание |
label
|
string
|
Метка может использоваться для указания ключа содержимого при создании указателя потоковой передачи
|
policyName
|
string
|
Политика, используемая ключом содержимого
|
tracks
|
TrackSelection[]
|
Отслеживает, в которых используется этот ключ содержимого
|
StreamingPolicyContentKeys
Класс для указания свойств всех ключей содержимого в политике потоковой передачи
Имя |
Тип |
Описание |
defaultKey
|
DefaultKey
|
Ключ содержимого по умолчанию для схемы шифрования
|
keyToTrackMappings
|
StreamingPolicyContentKey[]
|
Для представления дорожек требуется отдельный ключ содержимого
|
StreamingPolicyFairPlayConfiguration
Класс для указания конфигураций FairPlay в политике потоковой передачи
Имя |
Тип |
Описание |
allowPersistentLicense
|
boolean
|
Все лицензии должны быть постоянными или нет
|
customLicenseAcquisitionUrlTemplate
|
string
|
Шаблон для URL-адреса пользовательской службы, предоставляющей лицензии игрокам конечных пользователей. Не требуется при использовании Служб мультимедиа Azure для выдачи лицензий. Этот шаблон поддерживает заменяемые маркеры, которые служба будет обновлять во время выполнения, устанавливая значение, соответствующее запросу. В настоящее время поддерживаются значения маркера {AlternativeMediaId}, который заменяется значением StreamingLocatorId.AlternativeMediaId, и {ContentKeyId}, который заменяется значением идентификатора запрашиваемого ключа.
|
StreamingPolicyPlayReadyConfiguration
Класс для указания конфигураций PlayReady в политике потоковой передачи
Имя |
Тип |
Описание |
customLicenseAcquisitionUrlTemplate
|
string
|
Шаблон для URL-адреса пользовательской службы, предоставляющей лицензии игрокам конечных пользователей. Не требуется при использовании Служб мультимедиа Azure для выдачи лицензий. Этот шаблон поддерживает заменяемые маркеры, которые служба будет обновлять во время выполнения, устанавливая значение, соответствующее запросу. В настоящее время поддерживаются значения маркера {AlternativeMediaId}, который заменяется значением StreamingLocatorId.AlternativeMediaId и {ContentKeyId}, который заменяется значением идентификатора запрашиваемого ключа.
|
playReadyCustomAttributes
|
string
|
Настраиваемые атрибуты для PlayReady
|
StreamingPolicyWidevineConfiguration
Класс для указания конфигураций Widevine в политике потоковой передачи
Имя |
Тип |
Описание |
customLicenseAcquisitionUrlTemplate
|
string
|
Шаблон для URL-адреса пользовательской службы, предоставляющей лицензии игрокам конечных пользователей. Не требуется при использовании Служб мультимедиа Azure для выдачи лицензий. Этот шаблон поддерживает заменяемые маркеры, которые служба будет обновлять во время выполнения, устанавливая значение, соответствующее запросу. В настоящее время поддерживаются значения маркера {AlternativeMediaId}, который заменяется значением StreamingLocatorId.AlternativeMediaId и {ContentKeyId}, который заменяется значением идентификатора запрашиваемого ключа.
|
systemData
Метаданные, относящиеся к созданию и последнему изменению ресурса.
Имя |
Тип |
Описание |
createdAt
|
string
|
Метка времени создания ресурса (UTC).
|
createdBy
|
string
|
Удостоверение, создающее ресурс.
|
createdByType
|
createdByType
|
Тип удостоверения, создавшего ресурс.
|
lastModifiedAt
|
string
|
Метка времени последнего изменения ресурса (UTC)
|
lastModifiedBy
|
string
|
Удостоверение, которое в последний раз изменял ресурс.
|
lastModifiedByType
|
createdByType
|
Тип удостоверения, изменяющего ресурс в последний раз.
|
TrackPropertyCompareOperation
Отслеживание операции с условием свойства
Имя |
Тип |
Описание |
Equal
|
string
|
Операция равенства
|
Unknown
|
string
|
Операция сравнения свойств неизвестной трассы
|
TrackPropertyCondition
Класс для указания одного условия свойства track
TrackPropertyType
Отслеживание типа свойства
Имя |
Тип |
Описание |
FourCC
|
string
|
Отслеживание FourCC
|
Unknown
|
string
|
Неизвестное свойство track
|
TrackSelection
Класс для выбора дорожки
Имя |
Тип |
Описание |
trackSelections
|
TrackPropertyCondition[]
|
TrackSelections — это список условий свойств отслеживания, который может указывать треки.
|