Criar uma Política de Transmissão em Fluxo na conta dos Serviços de Multimédia
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}?api-version=2022-08-01
Parâmetros do URI
Name |
Em |
Necessário |
Tipo |
Description |
accountName
|
path |
True
|
string
|
O nome da conta dos Serviços de Multimédia.
|
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos na subscrição do Azure.
|
streamingPolicyName
|
path |
True
|
string
|
O nome da Política de Transmissão em Fluxo.
|
subscriptionId
|
path |
True
|
string
|
O identificador exclusivo de uma subscrição do Microsoft Azure.
|
api-version
|
query |
True
|
string
|
A versão da API a ser utilizada com o pedido de cliente.
|
Corpo do Pedido
Name |
Tipo |
Description |
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Configuração de CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Configuração do CommonEncryptionCenc
|
properties.defaultContentKeyPolicyName
|
string
|
ContentKey Predefinido utilizado pela Política de Transmissão em Fluxo atual
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Configuração de EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Configurações de NoEncryption
|
Respostas
Exemplos
Creates a Streaming Policy with clear streaming
Pedido de amostra
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
Resposta da amostra
{
"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.
Pedido de amostra
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
Resposta da amostra
{
"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.
Pedido de amostra
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
Resposta da amostra
{
"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
Pedido de amostra
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
Resposta da amostra
{
"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
Pedido de amostra
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
Resposta da amostra
{
"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
Pedido de amostra
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
Resposta da amostra
{
"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
Pedido de amostra
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
Resposta da amostra
{
"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
}
}
}
}
}
Definições
CbcsDrmConfiguration
Classe para especificar as configurações de DRM do esquema CommonEncryptionCbcs na Política de Transmissão em Fluxo
CencDrmConfiguration
Classe para especificar as configurações de DRM do esquema CommonEncryptionCenc na Política de Transmissão em Fluxo
ClearKeyEncryptionConfiguration
Classe para especificar a configuração ClearKey de esquemas de encriptação comuns na Política de Transmissão em Fluxo
Name |
Tipo |
Description |
customKeysAcquisitionUrlTemplate
|
string
|
Modelo para o URL do serviço personalizado que fornece chaves de conteúdo aos leitores de utilizadores finais. Não é necessário ao utilizar os Serviços de Multimédia do Azure para emitir licenças. O modelo suporta tokens substituíveis que o serviço irá atualizar no runtime com o valor específico do pedido. O valor do token atualmente suportado é {AlternativeMediaId}, que é substituído pelo valor de StreamingLocatorId.AlternativeMediaId.
|
CommonEncryptionCbcs
Classe para o esquema de encriptação CommonEncryptionCbcs
Name |
Tipo |
Description |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Configuração opcional que suporta ClearKey no esquema de encriptação CommonEncryptionCbcs.
|
clearTracks
|
TrackSelection[]
|
Representar as faixas que não devem ser encriptadas
|
contentKeys
|
StreamingPolicyContentKeys
|
Representar a chave de conteúdo predefinida para cada esquema de encriptação e chaves de conteúdo separadas para faixas específicas
|
drm
|
CbcsDrmConfiguration
|
Configuração de DRMs para o esquema de encriptação atual
|
enabledProtocols
|
EnabledProtocols
|
Representar protocolos suportados
|
CommonEncryptionCenc
Classe para esquema de encriptação de envelopes
Name |
Tipo |
Description |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Configuração opcional que suporta ClearKey no esquema de encriptação CommonEncryptionCenc.
|
clearTracks
|
TrackSelection[]
|
Representar as faixas que não devem ser encriptadas
|
contentKeys
|
StreamingPolicyContentKeys
|
Representar a chave de conteúdo predefinida para cada esquema de encriptação e chaves de conteúdo separadas para faixas específicas
|
drm
|
CencDrmConfiguration
|
Configuração de DRMs para o esquema de encriptação CommonEncryptionCenc
|
enabledProtocols
|
EnabledProtocols
|
Representar protocolos suportados
|
createdByType
O tipo de identidade que criou o recurso.
Name |
Tipo |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DefaultKey
Classe para especificar propriedades da chave de conteúdo predefinida para cada esquema de encriptação
Name |
Tipo |
Description |
label
|
string
|
A etiqueta pode ser utilizada para especificar a Chave de Conteúdo ao criar um Localizador de Transmissão em Fluxo
|
policyName
|
string
|
Política utilizada pela Chave Predefinida
|
EnabledProtocols
Classe para especificar que protocolos estão ativados
Name |
Tipo |
Description |
dash
|
boolean
|
Ativar ou não o protocolo DASH
|
download
|
boolean
|
Ativar o protocolo Transferir ou não
|
hls
|
boolean
|
Ativar ou não o protocolo HLS
|
smoothStreaming
|
boolean
|
Ativar ou não o protocolo SmoothStreaming
|
EnvelopeEncryption
Class for EnvelopeEncryption encryption scheme (Classe para EnvelopeEncryption encryption scheme)
Name |
Tipo |
Description |
clearTracks
|
TrackSelection[]
|
Representar as faixas que não devem ser encriptadas
|
contentKeys
|
StreamingPolicyContentKeys
|
Representar a chave de conteúdo predefinida para cada esquema de encriptação e chaves de conteúdo separadas para faixas específicas
|
customKeyAcquisitionUrlTemplate
|
string
|
Modelo para o URL do serviço personalizado que fornece chaves aos leitores de utilizadores finais. Não é necessário ao utilizar os Serviços de Multimédia do Azure para emitir chaves. O modelo suporta tokens substituíveis que o serviço irá atualizar no runtime com o valor específico do pedido. Os valores de token atualmente suportados são {AlternativeMediaId}, que é substituído pelo valor de StreamingLocatorId.AlternativeMediaId e {ContentKeyId}, que é substituído pelo valor do identificador da chave que está a ser pedida.
|
enabledProtocols
|
EnabledProtocols
|
Representar protocolos suportados
|
ErrorAdditionalInfo
Informações adicionais sobre o erro de gestão de recursos.
Name |
Tipo |
Description |
info
|
object
|
As informações adicionais.
|
type
|
string
|
O tipo de informações adicionais.
|
ErrorDetail
O detalhe do erro.
Name |
Tipo |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
As informações adicionais do erro.
|
code
|
string
|
O código de erro.
|
details
|
ErrorDetail[]
|
Os detalhes do erro.
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro.
|
ErrorResponse
Resposta a erros
Name |
Tipo |
Description |
error
|
ErrorDetail
|
O objeto de erro.
|
NoEncryption
Class for NoEncryption scheme (Classe para o esquema NoEncryption)
Name |
Tipo |
Description |
enabledProtocols
|
EnabledProtocols
|
Representar protocolos suportados
|
StreamingPolicy
Um recurso de Política de Transmissão em Fluxo
Name |
Tipo |
Description |
id
|
string
|
ID de recurso completamente qualificado para o recurso. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
O nome do recurso
|
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Configuração de CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Configuração do CommonEncryptionCenc
|
properties.created
|
string
|
Hora de criação da Política de Transmissão em Fluxo
|
properties.defaultContentKeyPolicyName
|
string
|
ContentKey Predefinido utilizado pela Política de Transmissão em Fluxo atual
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Configuração de EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Configurações do NoEncryption
|
systemData
|
systemData
|
Os metadados do sistema relacionados com este recurso.
|
type
|
string
|
O tipo de recurso. Por exemplo, "Microsoft.Compute/virtualMachines" ou "Microsoft.Storage/storageAccounts"
|
StreamingPolicyContentKey
Classe para especificar propriedades da chave de conteúdo
Name |
Tipo |
Description |
label
|
string
|
A etiqueta pode ser utilizada para especificar a Chave de Conteúdo ao criar um Localizador de Transmissão em Fluxo
|
policyName
|
string
|
Política utilizada pela Chave de Conteúdo
|
tracks
|
TrackSelection[]
|
Faixas que utilizam esta chave de conteúdo
|
StreamingPolicyContentKeys
Classe para especificar propriedades de todas as chaves de conteúdo na Política de Transmissão em Fluxo
Name |
Tipo |
Description |
defaultKey
|
DefaultKey
|
Chave de conteúdo predefinida para um esquema de encriptação
|
keyToTrackMappings
|
StreamingPolicyContentKey[]
|
Representar faixas precisa de uma chave de conteúdo separada
|
StreamingPolicyFairPlayConfiguration
Classe para especificar configurações do FairPlay na Política de Transmissão em Fluxo
Name |
Tipo |
Description |
allowPersistentLicense
|
boolean
|
Todas as licenças para serem persistentes ou não
|
customLicenseAcquisitionUrlTemplate
|
string
|
Modelo para o URL do serviço personalizado que fornece licenças aos leitores de utilizadores finais. Não é necessário ao utilizar os Serviços de Multimédia do Azure para emitir licenças. O modelo suporta tokens substituíveis que o serviço irá atualizar no runtime com o valor específico do pedido. Os valores de token atualmente suportados são {AlternativeMediaId}, que é substituído pelo valor de StreamingLocatorId.AlternativeMediaId e {ContentKeyId}, que é substituído pelo valor do identificador da chave que está a ser pedida.
|
StreamingPolicyPlayReadyConfiguration
Classe para especificar configurações do PlayReady na Política de Transmissão em Fluxo
Name |
Tipo |
Description |
customLicenseAcquisitionUrlTemplate
|
string
|
Modelo para o URL do serviço personalizado que fornece licenças aos leitores de utilizadores finais. Não é necessário ao utilizar os Serviços de Multimédia do Azure para emitir licenças. O modelo suporta tokens substituíveis que o serviço irá atualizar no runtime com o valor específico do pedido. Os valores de token atualmente suportados são {AlternativeMediaId}, que é substituído pelo valor de StreamingLocatorId.AlternativeMediaId e {ContentKeyId}, que é substituído pelo valor do identificador da chave que está a ser pedida.
|
playReadyCustomAttributes
|
string
|
Atributos personalizados para PlayReady
|
StreamingPolicyWidevineConfiguration
Classe para especificar configurações do Widevine na Política de Transmissão em Fluxo
Name |
Tipo |
Description |
customLicenseAcquisitionUrlTemplate
|
string
|
Modelo para o URL do serviço personalizado que fornece licenças aos leitores de utilizadores finais. Não é necessário ao utilizar os Serviços de Multimédia do Azure para emitir licenças. O modelo suporta tokens substituíveis que o serviço irá atualizar no runtime com o valor específico do pedido. Os valores de token atualmente suportados são {AlternativeMediaId}, que é substituído pelo valor de StreamingLocatorId.AlternativeMediaId e {ContentKeyId}, que é substituído pelo valor do identificador da chave que está a ser pedida.
|
systemData
Metadados relativos à criação e última modificação do recurso.
Name |
Tipo |
Description |
createdAt
|
string
|
O carimbo de data/hora da criação de recursos (UTC).
|
createdBy
|
string
|
A identidade que criou o recurso.
|
createdByType
|
createdByType
|
O tipo de identidade que criou o recurso.
|
lastModifiedAt
|
string
|
O carimbo de data/hora da última modificação do recurso (UTC)
|
lastModifiedBy
|
string
|
A identidade que modificou o recurso pela última vez.
|
lastModifiedByType
|
createdByType
|
O tipo de identidade que modificou o recurso pela última vez.
|
TrackPropertyCompareOperation
Controlar a operação de condição de propriedade
Name |
Tipo |
Description |
Equal
|
string
|
Operação de igual
|
Unknown
|
string
|
Operação de comparação de propriedades de registo desconhecida
|
TrackPropertyCondition
Classe para especificar uma condição de propriedade de registo
TrackPropertyType
Controlar o tipo de propriedade
Name |
Tipo |
Description |
FourCC
|
string
|
Controlar FourCC
|
Unknown
|
string
|
Propriedade de faixa desconhecida
|
TrackSelection
Classe para selecionar uma faixa
Name |
Tipo |
Description |
trackSelections
|
TrackPropertyCondition[]
|
TrackSelections é uma lista de condição de propriedade de registo que pode especificar faixas
|