Een streamingbeleid maken in het Media Services-account
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}?api-version=2022-08-01
URI-parameters
Name |
In |
Vereist |
Type |
Description |
accountName
|
path |
True
|
string
|
De naam van het Media Services-account.
|
resourceGroupName
|
path |
True
|
string
|
De naam van de resourcegroep binnen het Azure-abonnement.
|
streamingPolicyName
|
path |
True
|
string
|
De naam van het streamingbeleid.
|
subscriptionId
|
path |
True
|
string
|
De unieke id voor een Microsoft Azure-abonnement.
|
api-version
|
query |
True
|
string
|
De versie van de API die moet worden gebruikt met de clientaanvraag.
|
Aanvraagbody
Name |
Type |
Description |
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Configuratie van CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Configuratie van CommonEncryptionCenc
|
properties.defaultContentKeyPolicyName
|
string
|
Standaard ContentKey die wordt gebruikt door het huidige streamingbeleid
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Configuratie van EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Configuraties van NoEncryption
|
Antwoorden
Voorbeelden
Creates a Streaming Policy with clear streaming
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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.
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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.
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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
}
}
}
}
}
Definities
CbcsDrmConfiguration
Klasse voor het opgeven van DRM-configuraties van het CommonEncryptionCbcs-schema in streamingbeleid
CencDrmConfiguration
Klasse voor het opgeven van DRM-configuraties van het CommonEncryptionCenc-schema in streamingbeleid
ClearKeyEncryptionConfiguration
Klasse voor het opgeven van clearkey-configuratie van algemene versleutelingsschema's in streamingbeleid
Name |
Type |
Description |
customKeysAcquisitionUrlTemplate
|
string
|
Sjabloon voor de URL van de aangepaste service die inhoudssleutels levert aan eindgebruikers. Niet vereist bij het gebruik van Azure Media Services voor het verlenen van licenties. De sjabloon ondersteunt vervangbare tokens die de service tijdens runtime bijwerkt met de waarde die specifiek is voor de aanvraag. De momenteel ondersteunde tokenwaarde is {AlternativeMediaId}, die wordt vervangen door de waarde van StreamingLocatorId.AlternativeMediaId.
|
CommonEncryptionCbcs
Klasse voor CommonEncryptionCbcs-versleutelingsschema
Name |
Type |
Description |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Optionele configuratie die ClearKey ondersteunt in commonEncryptionCbcs-versleutelingsschema.
|
clearTracks
|
TrackSelection[]
|
Vertegenwoordigen welke sporen niet mogen worden versleuteld
|
contentKeys
|
StreamingPolicyContentKeys
|
Vertegenwoordigt de standaardinhoudssleutel voor elk versleutelingsschema en afzonderlijke inhoudssleutels voor specifieke nummers
|
drm
|
CbcsDrmConfiguration
|
Configuratie van DRM's voor het huidige versleutelingsschema
|
enabledProtocols
|
EnabledProtocols
|
Ondersteunde protocollen vertegenwoordigen
|
CommonEncryptionCenc
Klasse voor envelopversleutelingsschema
Name |
Type |
Description |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Optionele configuratie die ClearKey ondersteunt in het versleutelingsschema CommonEncryptionCenc.
|
clearTracks
|
TrackSelection[]
|
Vertegenwoordigen welke sporen niet mogen worden versleuteld
|
contentKeys
|
StreamingPolicyContentKeys
|
Vertegenwoordigt de standaardinhoudssleutel voor elk versleutelingsschema en afzonderlijke inhoudssleutels voor specifieke nummers
|
drm
|
CencDrmConfiguration
|
Configuratie van DRM's voor CommonEncryptionCenc-versleutelingsschema
|
enabledProtocols
|
EnabledProtocols
|
Ondersteunde protocollen vertegenwoordigen
|
createdByType
Het type identiteit waarmee de resource is gemaakt.
Name |
Type |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DefaultKey
Klasse voor het opgeven van eigenschappen van de standaardinhoudssleutel voor elk versleutelingsschema
Name |
Type |
Description |
label
|
string
|
Label kan worden gebruikt om inhoudssleutel op te geven bij het maken van een streaming-locator
|
policyName
|
string
|
Beleid dat wordt gebruikt door de standaardsleutel
|
EnabledProtocols
Klasse om op te geven welke protocollen zijn ingeschakeld
Name |
Type |
Description |
dash
|
boolean
|
DASH-protocol inschakelen of niet
|
download
|
boolean
|
Downloadprotocol inschakelen of niet
|
hls
|
boolean
|
HLS-protocol inschakelen of niet
|
smoothStreaming
|
boolean
|
SmoothStreaming-protocol inschakelen of niet
|
EnvelopeEncryption
Klasse voor EnvelopVersleutelingsschema
Name |
Type |
Description |
clearTracks
|
TrackSelection[]
|
Vertegenwoordigen welke sporen niet mogen worden versleuteld
|
contentKeys
|
StreamingPolicyContentKeys
|
Vertegenwoordigt de standaardinhoudssleutel voor elk versleutelingsschema en afzonderlijke inhoudssleutels voor specifieke nummers
|
customKeyAcquisitionUrlTemplate
|
string
|
Sjabloon voor de URL van de aangepaste service die sleutels levert aan eindgebruikers. Niet vereist bij het gebruik van Azure Media Services voor het uitgeven van sleutels. De sjabloon ondersteunt vervangbare tokens die de service tijdens runtime bijwerkt met de waarde die specifiek is voor de aanvraag. De momenteel ondersteunde tokenwaarden zijn {AlternativeMediaId}, die wordt vervangen door de waarde van StreamingLocatorId.AlternativeMediaId en {ContentKeyId}, die wordt vervangen door de waarde van de id van de sleutel die wordt aangevraagd.
|
enabledProtocols
|
EnabledProtocols
|
Ondersteunde protocollen vertegenwoordigen
|
ErrorAdditionalInfo
Aanvullende informatie over de resourcebeheerfout.
Name |
Type |
Description |
info
|
object
|
De aanvullende informatie.
|
type
|
string
|
Het type aanvullende informatie.
|
ErrorDetail
De foutdetails.
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
De fout aanvullende informatie.
|
code
|
string
|
De foutcode.
|
details
|
ErrorDetail[]
|
De foutdetails.
|
message
|
string
|
Het foutbericht.
|
target
|
string
|
Het foutdoel.
|
ErrorResponse
Foutreactie
Name |
Type |
Description |
error
|
ErrorDetail
|
Het foutobject.
|
NoEncryption
Klasse voor NoEncryption-schema
Name |
Type |
Description |
enabledProtocols
|
EnabledProtocols
|
Ondersteunde protocollen vertegenwoordigen
|
StreamingPolicy
Een streamingbeleidsresource
Name |
Type |
Description |
id
|
string
|
Volledig gekwalificeerde resource-id voor de resource. Bijvoorbeeld - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
De naam van de resource
|
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Configuratie van CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Configuratie van CommonEncryptionCenc
|
properties.created
|
string
|
Aanmaaktijd van streamingbeleid
|
properties.defaultContentKeyPolicyName
|
string
|
Standaard ContentKey die wordt gebruikt door het huidige streamingbeleid
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Configuratie van EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Configuraties van NoEncryption
|
systemData
|
systemData
|
De systeemmetagegevens met betrekking tot deze resource.
|
type
|
string
|
Het type resource. Bijvoorbeeld 'Microsoft.Compute/virtualMachines' of 'Microsoft.Storage/storageAccounts'
|
StreamingPolicyContentKey
Klasse om eigenschappen van inhoudssleutel op te geven
Name |
Type |
Description |
label
|
string
|
Label kan worden gebruikt om inhoudssleutel op te geven bij het maken van een streaming-locator
|
policyName
|
string
|
Beleid dat wordt gebruikt door inhoudssleutel
|
tracks
|
TrackSelection[]
|
Houdt bij welke inhoudssleutel wordt gebruikt
|
StreamingPolicyContentKeys
Klasse voor het opgeven van eigenschappen van alle inhoudssleutels in streamingbeleid
Name |
Type |
Description |
defaultKey
|
DefaultKey
|
Standaardinhoudssleutel voor een versleutelingsschema
|
keyToTrackMappings
|
StreamingPolicyContentKey[]
|
Voor het weergeven van sporen is een afzonderlijke inhoudssleutel vereist
|
StreamingPolicyFairPlayConfiguration
Klasse om configuraties van FairPlay op te geven in streamingbeleid
Name |
Type |
Description |
allowPersistentLicense
|
boolean
|
Alle licenties die permanent moeten zijn of niet
|
customLicenseAcquisitionUrlTemplate
|
string
|
Sjabloon voor de URL van de aangepaste service die licenties levert aan eindgebruikers. Niet vereist bij het gebruik van Azure Media Services voor het verlenen van licenties. De sjabloon ondersteunt vervangbare tokens die de service tijdens runtime bijwerkt met de waarde die specifiek is voor de aanvraag. De momenteel ondersteunde tokenwaarden zijn {AlternativeMediaId}, die wordt vervangen door de waarde StreamingLocatorId.AlternativeMediaId en {ContentKeyId}, die wordt vervangen door de waarde van de id van de sleutel die wordt aangevraagd.
|
StreamingPolicyPlayReadyConfiguration
Klasse om configuraties van PlayReady op te geven in streamingbeleid
Name |
Type |
Description |
customLicenseAcquisitionUrlTemplate
|
string
|
Sjabloon voor de URL van de aangepaste service die licenties levert aan eindgebruikers. Niet vereist bij het gebruik van Azure Media Services voor het verlenen van licenties. De sjabloon ondersteunt vervangbare tokens die de service tijdens runtime bijwerkt met de waarde die specifiek is voor de aanvraag. De momenteel ondersteunde tokenwaarden zijn {AlternativeMediaId}, die wordt vervangen door de waarde van StreamingLocatorId.AlternativeMediaId en {ContentKeyId}, die wordt vervangen door de waarde van de id van de sleutel die wordt aangevraagd.
|
playReadyCustomAttributes
|
string
|
Aangepaste kenmerken voor PlayReady
|
StreamingPolicyWidevineConfiguration
Klasse om configuraties van Widevine op te geven in streamingbeleid
Name |
Type |
Description |
customLicenseAcquisitionUrlTemplate
|
string
|
Sjabloon voor de URL van de aangepaste service die licenties levert aan eindgebruikers. Niet vereist bij het gebruik van Azure Media Services voor het verlenen van licenties. De sjabloon ondersteunt vervangbare tokens die de service tijdens runtime bijwerkt met de waarde die specifiek is voor de aanvraag. De momenteel ondersteunde tokenwaarden zijn {AlternativeMediaId}, die wordt vervangen door de waarde van StreamingLocatorId.AlternativeMediaId en {ContentKeyId}, die wordt vervangen door de waarde van de id van de sleutel die wordt aangevraagd.
|
systemData
Metagegevens met betrekking tot het maken en laatste wijzigen van de resource.
Name |
Type |
Description |
createdAt
|
string
|
De tijdstempel van het maken van resources (UTC).
|
createdBy
|
string
|
De identiteit die de resource heeft gemaakt.
|
createdByType
|
createdByType
|
Het type identiteit waarmee de resource is gemaakt.
|
lastModifiedAt
|
string
|
Het tijdstempel van de laatste wijziging van de resource (UTC)
|
lastModifiedBy
|
string
|
De identiteit die de resource het laatst heeft gewijzigd.
|
lastModifiedByType
|
createdByType
|
Het type identiteit dat de resource het laatst heeft gewijzigd.
|
TrackPropertyCompareOperation
Bewerking eigenschapsvoorwaarde bijhouden
Name |
Type |
Description |
Equal
|
string
|
Gelijke bewerking
|
Unknown
|
string
|
Onbekende vergelijkingsbewerking voor traceereigenschappen
|
TrackPropertyCondition
Klasse voor het opgeven van één voorwaarde voor de eigenschap track
TrackPropertyType
Type eigenschap bijhouden
Name |
Type |
Description |
FourCC
|
string
|
FourCC bijhouden
|
Unknown
|
string
|
Onbekende trackeigenschap
|
TrackSelection
Klas om een nummer te selecteren
Name |
Type |
Description |
trackSelections
|
TrackPropertyCondition[]
|
TrackSelections is een lijst met voorwaarden voor trackeigenschappen waarmee u track(s) kunt opgeven
|