Tworzenie zasad przesyłania strumieniowego na koncie usługi Media Services
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}?api-version=2022-08-01
Parametry identyfikatora URI
Nazwa |
W |
Wymagane |
Typ |
Opis |
accountName
|
path |
True
|
string
|
Nazwa konta usługi Media Services.
|
resourceGroupName
|
path |
True
|
string
|
Nazwa grupy zasobów w ramach subskrypcji platformy Azure.
|
streamingPolicyName
|
path |
True
|
string
|
Nazwa zasad przesyłania strumieniowego.
|
subscriptionId
|
path |
True
|
string
|
Unikatowy identyfikator subskrypcji platformy Microsoft Azure.
|
api-version
|
query |
True
|
string
|
Wersja interfejsu API, która ma być używana z żądaniem klienta.
|
Treść żądania
Nazwa |
Typ |
Opis |
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Konfiguracja commonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Konfiguracja biblioteki CommonEncryptionCenc
|
properties.defaultContentKeyPolicyName
|
string
|
Domyślny klucz zawartości używany przez bieżące zasady przesyłania strumieniowego
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Konfiguracja elementu EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Konfiguracje noEncryption
|
Odpowiedzi
Przykłady
Creates a Streaming Policy with clear streaming
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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.
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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.
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
}
}
}
}
}
Definicje
CbcsDrmConfiguration
Klasa określająca konfiguracje DRM schematu CommonEncryptionCbcs w zasadach przesyłania strumieniowego
CencDrmConfiguration
Klasa określająca konfiguracje DRM schematu CommonEncryptionCenc w zasadach przesyłania strumieniowego
ClearKeyEncryptionConfiguration
Klasa określająca konfigurację ClearKey typowych schematów szyfrowania w zasadach przesyłania strumieniowego
Nazwa |
Typ |
Opis |
customKeysAcquisitionUrlTemplate
|
string
|
Szablon adresu URL usługi niestandardowej dostarczającej klucze zawartości graczom końcowym. Nie jest wymagane w przypadku używania usługi Azure Media Services do wydawania licencji. Szablon obsługuje zastępowalne tokeny, które usługa zaktualizuje w czasie wykonywania przy użyciu wartości specyficznej dla żądania. Obecnie obsługiwana wartość tokenu to {AlternativeMediaId}, która jest zastępowana wartością StreamingLocatorId.AlternativeMediaId.
|
CommonEncryptionCbcs
Klasa dla schematu szyfrowania CommonEncryptionCbcs
Nazwa |
Typ |
Opis |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Opcjonalna konfiguracja obsługująca klucz ClearKey w schemacie szyfrowania CommonEncryptionCbcs.
|
clearTracks
|
TrackSelection[]
|
Przedstawianie, które ścieżki nie powinny być szyfrowane
|
contentKeys
|
StreamingPolicyContentKeys
|
Reprezentowanie domyślnego klucza zawartości dla każdego schematu szyfrowania i oddzielnych kluczy zawartości dla określonych ścieżek
|
drm
|
CbcsDrmConfiguration
|
Konfiguracja drM dla bieżącego schematu szyfrowania
|
enabledProtocols
|
EnabledProtocols
|
Reprezentowanie obsługiwanych protokołów
|
CommonEncryptionCenc
Klasa schematu szyfrowania kopert
Nazwa |
Typ |
Opis |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Opcjonalna konfiguracja obsługująca klucz ClearKey w schemacie szyfrowania CommonEncryptionCenc.
|
clearTracks
|
TrackSelection[]
|
Przedstawianie, które ścieżki nie powinny być szyfrowane
|
contentKeys
|
StreamingPolicyContentKeys
|
Reprezentowanie domyślnego klucza zawartości dla każdego schematu szyfrowania i oddzielnych kluczy zawartości dla określonych ścieżek
|
drm
|
CencDrmConfiguration
|
Konfiguracja drM dla schematu szyfrowania CommonEncryptionCenc
|
enabledProtocols
|
EnabledProtocols
|
Reprezentowanie obsługiwanych protokołów
|
createdByType
Typ tożsamości, która utworzyła zasób.
Nazwa |
Typ |
Opis |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DefaultKey
Klasa określająca właściwości domyślnego klucza zawartości dla każdego schematu szyfrowania
Nazwa |
Typ |
Opis |
label
|
string
|
Etykieta może służyć do określania klucza zawartości podczas tworzenia lokalizatora przesyłania strumieniowego
|
policyName
|
string
|
Zasady używane przez klucz domyślny
|
EnabledProtocols
Klasa określająca, które protokoły są włączone
Nazwa |
Typ |
Opis |
dash
|
boolean
|
Włączanie protokołu DASH lub nie
|
download
|
boolean
|
Włącz protokół pobierania lub nie
|
hls
|
boolean
|
Włączanie protokołu HLS lub nie
|
smoothStreaming
|
boolean
|
Włączanie protokołu SmoothStreaming lub nie
|
EnvelopeEncryption
Klasa dla schematu szyfrowania EnvelopeEncryption
Nazwa |
Typ |
Opis |
clearTracks
|
TrackSelection[]
|
Przedstawianie, które ścieżki nie powinny być szyfrowane
|
contentKeys
|
StreamingPolicyContentKeys
|
Reprezentowanie domyślnego klucza zawartości dla każdego schematu szyfrowania i oddzielnych kluczy zawartości dla określonych ścieżek
|
customKeyAcquisitionUrlTemplate
|
string
|
Szablon adresu URL usługi niestandardowej dostarczającej klucze do graczy użytkowników końcowych. Nie jest wymagane w przypadku używania usługi Azure Media Services do wystawiania kluczy. Szablon obsługuje zastępowalne tokeny, które usługa zaktualizuje w czasie wykonywania przy użyciu wartości specyficznej dla żądania. Obecnie obsługiwane wartości tokenu to {AlternativeMediaId}, który jest zastępowany wartością StreamingLocatorId.AlternativeMediaId i {ContentKeyId}, która jest zastępowana wartością identyfikatora żądanego klucza.
|
enabledProtocols
|
EnabledProtocols
|
Reprezentowanie obsługiwanych protokołów
|
ErrorAdditionalInfo
Dodatkowe informacje o błędzie zarządzania zasobami.
Nazwa |
Typ |
Opis |
info
|
object
|
Dodatkowe informacje.
|
type
|
string
|
Dodatkowy typ informacji.
|
ErrorDetail
Szczegóły błędu.
Nazwa |
Typ |
Opis |
additionalInfo
|
ErrorAdditionalInfo[]
|
Dodatkowe informacje o błędzie.
|
code
|
string
|
Kod błędu.
|
details
|
ErrorDetail[]
|
Szczegóły błędu.
|
message
|
string
|
Komunikat o błędzie.
|
target
|
string
|
Element docelowy błędu.
|
ErrorResponse
Odpowiedź na błąd
NoEncryption
Klasa dla schematu NoEncryption
Nazwa |
Typ |
Opis |
enabledProtocols
|
EnabledProtocols
|
Reprezentowanie obsługiwanych protokołów
|
StreamingPolicy
Zasób zasad przesyłania strumieniowego
Nazwa |
Typ |
Opis |
id
|
string
|
W pełni kwalifikowany identyfikator zasobu dla zasobu. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
Nazwa zasobu
|
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Konfiguracja commonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Konfiguracja biblioteki CommonEncryptionCenc
|
properties.created
|
string
|
Czas tworzenia zasad przesyłania strumieniowego
|
properties.defaultContentKeyPolicyName
|
string
|
Domyślny klucz zawartości używany przez bieżące zasady przesyłania strumieniowego
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Konfiguracja elementu EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Konfiguracje noEncryption
|
systemData
|
systemData
|
Metadane systemowe odnoszące się do tego zasobu.
|
type
|
string
|
Typ zasobu. Np. "Microsoft.Compute/virtualMachines" lub "Microsoft.Storage/storageAccounts"
|
StreamingPolicyContentKey
Klasa określająca właściwości klucza zawartości
Nazwa |
Typ |
Opis |
label
|
string
|
Etykieta może służyć do określania klucza zawartości podczas tworzenia lokalizatora przesyłania strumieniowego
|
policyName
|
string
|
Zasady używane przez klucz zawartości
|
tracks
|
TrackSelection[]
|
Śledzi, które używają tego klucza zawartości
|
StreamingPolicyContentKeys
Klasa określająca właściwości wszystkich kluczy zawartości w zasadach przesyłania strumieniowego
Nazwa |
Typ |
Opis |
defaultKey
|
DefaultKey
|
Domyślny klucz zawartości schematu szyfrowania
|
keyToTrackMappings
|
StreamingPolicyContentKey[]
|
Reprezentowanie ścieżek wymaga oddzielnego klucza zawartości
|
StreamingPolicyFairPlayConfiguration
Klasa określająca konfiguracje technologii FairPlay w zasadach przesyłania strumieniowego
Nazwa |
Typ |
Opis |
allowPersistentLicense
|
boolean
|
Wszystkie licencje, które mają być trwałe lub nie
|
customLicenseAcquisitionUrlTemplate
|
string
|
Szablon adresu URL usługi niestandardowej dostarczającej licencje graczom użytkowników końcowych. Nie jest wymagane w przypadku używania usługi Azure Media Services do wydawania licencji. Szablon obsługuje zastępowalne tokeny, które usługa zaktualizuje w czasie wykonywania przy użyciu wartości specyficznej dla żądania. Obecnie obsługiwane wartości tokenu to {AlternativeMediaId}, który jest zastępowany wartością StreamingLocatorId.AlternativeMediaId i {ContentKeyId}, która jest zastępowana wartością identyfikatora żądanego klucza.
|
StreamingPolicyPlayReadyConfiguration
Klasa określająca konfiguracje elementu PlayReady w zasadach przesyłania strumieniowego
Nazwa |
Typ |
Opis |
customLicenseAcquisitionUrlTemplate
|
string
|
Szablon adresu URL usługi niestandardowej dostarczającej licencje graczom użytkowników końcowych. Nie jest wymagane w przypadku używania usługi Azure Media Services do wydawania licencji. Szablon obsługuje zastępowalne tokeny, które usługa zaktualizuje w czasie wykonywania przy użyciu wartości specyficznej dla żądania. Obecnie obsługiwane wartości tokenu to {AlternativeMediaId}, który jest zastępowany wartością StreamingLocatorId.AlternativeMediaId i {ContentKeyId}, która jest zastępowana wartością identyfikatora żądanego klucza.
|
playReadyCustomAttributes
|
string
|
Atrybuty niestandardowe dla elementu PlayReady
|
StreamingPolicyWidevineConfiguration
Klasa określająca konfiguracje widevine w zasadach przesyłania strumieniowego
Nazwa |
Typ |
Opis |
customLicenseAcquisitionUrlTemplate
|
string
|
Szablon adresu URL usługi niestandardowej dostarczającej licencje graczom użytkowników końcowych. Nie jest wymagane w przypadku używania usługi Azure Media Services do wydawania licencji. Szablon obsługuje zastępowalne tokeny, które usługa zaktualizuje w czasie wykonywania przy użyciu wartości specyficznej dla żądania. Obecnie obsługiwane wartości tokenu to {AlternativeMediaId}, który jest zastępowany wartością StreamingLocatorId.AlternativeMediaId i {ContentKeyId}, która jest zastępowana wartością identyfikatora żądanego klucza.
|
systemData
Metadane dotyczące tworzenia i ostatniej modyfikacji zasobu.
Nazwa |
Typ |
Opis |
createdAt
|
string
|
Sygnatura czasowa tworzenia zasobów (UTC).
|
createdBy
|
string
|
Tożsamość, która utworzyła zasób.
|
createdByType
|
createdByType
|
Typ tożsamości, która utworzyła zasób.
|
lastModifiedAt
|
string
|
Sygnatura czasowa ostatniej modyfikacji zasobu (UTC)
|
lastModifiedBy
|
string
|
Tożsamość, która ostatnio zmodyfikowała zasób.
|
lastModifiedByType
|
createdByType
|
Typ tożsamości, która ostatnio zmodyfikowała zasób.
|
TrackPropertyCompareOperation
Śledzenie operacji warunku właściwości
Nazwa |
Typ |
Opis |
Equal
|
string
|
Równa operacja
|
Unknown
|
string
|
Nieznana operacja porównywania właściwości śledzenia
|
TrackPropertyCondition
Klasa określająca warunek jednej właściwości śledzenia
TrackPropertyType
Śledzenie typu właściwości
Nazwa |
Typ |
Opis |
FourCC
|
string
|
Track FourCC
|
Unknown
|
string
|
Nieznana właściwość ścieżki
|
TrackSelection
Klasa do wybierania ścieżki
Nazwa |
Typ |
Opis |
trackSelections
|
TrackPropertyCondition[]
|
TrackSelections to lista warunków śledzenia właściwości, która może określać ścieżki
|