Skapa en direktuppspelningsprincip i Media Services-kontot
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingPolicies/{streamingPolicyName}?api-version=2022-08-01
URI-parametrar
Name |
I |
Obligatorisk |
Typ |
Description |
accountName
|
path |
True
|
string
|
Media Services-kontonamnet.
|
resourceGroupName
|
path |
True
|
string
|
Namnet på resursgruppen i Azure-prenumerationen.
|
streamingPolicyName
|
path |
True
|
string
|
Namnet på strömningsprincipen.
|
subscriptionId
|
path |
True
|
string
|
Den unika identifieraren för en Microsoft Azure-prenumeration.
|
api-version
|
query |
True
|
string
|
Den version av API:et som ska användas med klientbegäran.
|
Begärandetext
Name |
Typ |
Description |
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Konfiguration av CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Konfiguration av CommonEncryptionCenc
|
properties.defaultContentKeyPolicyName
|
string
|
Standardinnehållsnyckel som används av aktuell direktuppspelningsprincip
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Konfiguration av EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Konfigurationer av NoEncryption
|
Svar
Exempel
Creates a Streaming Policy with clear streaming
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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.
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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.
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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
Exempelbegäran
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://video2.skills-academy.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
Exempelsvar
{
"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
}
}
}
}
}
Definitioner
CbcsDrmConfiguration
Klass för att ange DRM-konfigurationer för CommonEncryptionCbcs-schema i strömningsprincipen
CencDrmConfiguration
Klass för att ange DRM-konfigurationer för CommonEncryptionCenc-schema i direktuppspelningsprincip
ClearKeyEncryptionConfiguration
Klass för att ange ClearKey-konfiguration av vanliga krypteringsscheman i strömningsprincipen
Name |
Typ |
Description |
customKeysAcquisitionUrlTemplate
|
string
|
Mall för URL:en för den anpassade tjänsten som levererar innehållsnycklar till slutanvändarspelare. Krävs inte när du använder Azure Media Services för att utfärda licenser. Mallen stöder utbytbara token som tjänsten kommer att uppdatera vid körning med det värde som är specifikt för begäran. Tokenvärdet som stöds för närvarande är {AlternativeMediaId}, som ersätts med värdet StreamingLocatorId.AlternativeMediaId.
|
CommonEncryptionCbcs
Klass för CommonEncryptionCbcs-krypteringsschema
Name |
Typ |
Description |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Valfri konfiguration som stöder ClearKey i CommonEncryptionCbcs-krypteringsschema.
|
clearTracks
|
TrackSelection[]
|
Representerar vilka spår som inte ska krypteras
|
contentKeys
|
StreamingPolicyContentKeys
|
Representerar standardinnehållsnyckeln för varje krypteringsschema och separata innehållsnycklar för specifika spår
|
drm
|
CbcsDrmConfiguration
|
Konfiguration av DRM:er för aktuellt krypteringsschema
|
enabledProtocols
|
EnabledProtocols
|
Representerar protokoll som stöds
|
CommonEncryptionCenc
Klass för kuvertkrypteringsschema
Name |
Typ |
Description |
clearKeyEncryptionConfiguration
|
ClearKeyEncryptionConfiguration
|
Valfri konfiguration som stöder ClearKey i CommonEncryptionCenc-krypteringsschema.
|
clearTracks
|
TrackSelection[]
|
Representerar vilka spår som inte ska krypteras
|
contentKeys
|
StreamingPolicyContentKeys
|
Representerar standardinnehållsnyckeln för varje krypteringsschema och separata innehållsnycklar för specifika spår
|
drm
|
CencDrmConfiguration
|
Konfiguration av DRM:er för CommonEncryptionCenc-krypteringsschema
|
enabledProtocols
|
EnabledProtocols
|
Representerar protokoll som stöds
|
createdByType
Den typ av identitet som skapade resursen.
Name |
Typ |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DefaultKey
Klass för att ange egenskaper för standardinnehållsnyckeln för varje krypteringsschema
Name |
Typ |
Description |
label
|
string
|
Etikett kan användas för att ange innehållsnyckel när du skapar en positionerare för direktuppspelning
|
policyName
|
string
|
Princip som används av standardnyckeln
|
EnabledProtocols
Klass för att ange vilka protokoll som är aktiverade
Name |
Typ |
Description |
dash
|
boolean
|
Aktivera DASH-protokoll eller inte
|
download
|
boolean
|
Aktivera nedladdningsprotokoll eller inte
|
hls
|
boolean
|
Aktivera HLS-protokoll eller inte
|
smoothStreaming
|
boolean
|
Aktivera SmoothStreaming-protokollet eller inte
|
EnvelopeEncryption
Klass för Krypteringsschema för EnvelopeEncryption
Name |
Typ |
Description |
clearTracks
|
TrackSelection[]
|
Representerar vilka spår som inte ska krypteras
|
contentKeys
|
StreamingPolicyContentKeys
|
Representerar standardinnehållsnyckeln för varje krypteringsschema och separata innehållsnycklar för specifika spår
|
customKeyAcquisitionUrlTemplate
|
string
|
Mall för URL:en för den anpassade tjänsten som levererar nycklar till slutanvändare. Krävs inte när du använder Azure Media Services för att utfärda nycklar. Mallen stöder utbytbara token som tjänsten kommer att uppdatera vid körning med det värde som är specifikt för begäran. De tokenvärden som stöds för närvarande är {AlternativeMediaId}, som ersätts med värdet StreamingLocatorId.AlternativeMediaId och {ContentKeyId}, som ersätts med värdet för identifieraren för nyckeln som begärs.
|
enabledProtocols
|
EnabledProtocols
|
Representerar protokoll som stöds
|
ErrorAdditionalInfo
Ytterligare information om resurshanteringsfelet.
Name |
Typ |
Description |
info
|
object
|
Ytterligare information.
|
type
|
string
|
Den ytterligare informationstypen.
|
ErrorDetail
Felinformationen.
Name |
Typ |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Ytterligare information om felet.
|
code
|
string
|
Felkoden.
|
details
|
ErrorDetail[]
|
Felinformationen.
|
message
|
string
|
Felmeddelandet.
|
target
|
string
|
Felmålet.
|
ErrorResponse
Felsvar
NoEncryption
Klass för NoEncryption-schema
Name |
Typ |
Description |
enabledProtocols
|
EnabledProtocols
|
Representerar protokoll som stöds
|
StreamingPolicy
En resurs för direktuppspelningsprincip
Name |
Typ |
Description |
id
|
string
|
Fullständigt kvalificerat resurs-ID för resursen. Ex – /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
Namnet på resursen
|
properties.commonEncryptionCbcs
|
CommonEncryptionCbcs
|
Konfiguration av CommonEncryptionCbcs
|
properties.commonEncryptionCenc
|
CommonEncryptionCenc
|
Konfiguration av CommonEncryptionCenc
|
properties.created
|
string
|
Skapandetid för direktuppspelningsprincip
|
properties.defaultContentKeyPolicyName
|
string
|
Standardinnehållsnyckel som används av aktuell direktuppspelningsprincip
|
properties.envelopeEncryption
|
EnvelopeEncryption
|
Konfiguration av EnvelopeEncryption
|
properties.noEncryption
|
NoEncryption
|
Konfigurationer av NoEncryption
|
systemData
|
systemData
|
Systemmetadata som är relaterade till den här resursen.
|
type
|
string
|
Resurstypen. Till exempel "Microsoft.Compute/virtualMachines" eller "Microsoft.Storage/storageAccounts"
|
StreamingPolicyContentKey
Klass för att ange egenskaper för innehållsnyckeln
Name |
Typ |
Description |
label
|
string
|
Etikett kan användas för att ange innehållsnyckel när du skapar en positionerare för direktuppspelning
|
policyName
|
string
|
Princip som används av innehållsnyckel
|
tracks
|
TrackSelection[]
|
Spårar vilka som använder den här innehållsnyckeln
|
StreamingPolicyContentKeys
Klass för att ange egenskaper för alla innehållsnycklar i direktuppspelningsprincip
Name |
Typ |
Description |
defaultKey
|
DefaultKey
|
Standardinnehållsnyckel för ett krypteringsschema
|
keyToTrackMappings
|
StreamingPolicyContentKey[]
|
För att representera spår krävs en separat innehållsnyckel
|
StreamingPolicyFairPlayConfiguration
Klass för att ange konfigurationer av FairPlay i direktuppspelningsprincip
Name |
Typ |
Description |
allowPersistentLicense
|
boolean
|
Alla licenser ska vara beständiga eller inte
|
customLicenseAcquisitionUrlTemplate
|
string
|
Mall för URL:en för den anpassade tjänsten som levererar licenser till slutanvändarspelare. Krävs inte när du använder Azure Media Services för att utfärda licenser. Mallen stöder utbytbara token som tjänsten kommer att uppdatera vid körning med det värde som är specifikt för begäran. De tokenvärden som stöds för närvarande är {AlternativeMediaId}, som ersätts med värdet StreamingLocatorId.AlternativeMediaId och {ContentKeyId}, som ersätts med värdet för identifieraren för nyckeln som begärs.
|
StreamingPolicyPlayReadyConfiguration
Klass för att ange konfigurationer av PlayReady i direktuppspelningsprincip
Name |
Typ |
Description |
customLicenseAcquisitionUrlTemplate
|
string
|
Mall för URL:en för den anpassade tjänsten som levererar licenser till slutanvändarspelare. Krävs inte när du använder Azure Media Services för att utfärda licenser. Mallen stöder utbytbara token som tjänsten kommer att uppdatera vid körning med det värde som är specifikt för begäran. De tokenvärden som stöds för närvarande är {AlternativeMediaId}, som ersätts med värdet StreamingLocatorId.AlternativeMediaId och {ContentKeyId}, som ersätts med värdet för identifieraren för nyckeln som begärs.
|
playReadyCustomAttributes
|
string
|
Anpassade attribut för PlayReady
|
StreamingPolicyWidevineConfiguration
Klass för att ange konfigurationer av Widevine i direktuppspelningsprincip
Name |
Typ |
Description |
customLicenseAcquisitionUrlTemplate
|
string
|
Mall för URL:en för den anpassade tjänsten som levererar licenser till slutanvändarspelare. Krävs inte när du använder Azure Media Services för att utfärda licenser. Mallen stöder utbytbara token som tjänsten kommer att uppdatera vid körning med det värde som är specifikt för begäran. De tokenvärden som stöds för närvarande är {AlternativeMediaId}, som ersätts med värdet StreamingLocatorId.AlternativeMediaId och {ContentKeyId}, som ersätts med värdet för identifieraren för nyckeln som begärs.
|
systemData
Metadata som rör skapande och senaste ändring av resursen.
Name |
Typ |
Description |
createdAt
|
string
|
Tidsstämpeln för resursskapande (UTC).
|
createdBy
|
string
|
Identiteten som skapade resursen.
|
createdByType
|
createdByType
|
Den typ av identitet som skapade resursen.
|
lastModifiedAt
|
string
|
Tidsstämpeln för resursens senaste ändring (UTC)
|
lastModifiedBy
|
string
|
Identiteten som senast ändrade resursen.
|
lastModifiedByType
|
createdByType
|
Den typ av identitet som senast ändrade resursen.
|
TrackPropertyCompareOperation
Spåra egenskapsvillkorsåtgärd
Name |
Typ |
Description |
Equal
|
string
|
Lika med åtgärd
|
Unknown
|
string
|
Jämförelseåtgärd för okänd spårningsegenskap
|
TrackPropertyCondition
Klass för att ange ett egenskapsvillkor för spår
TrackPropertyType
Spåra egenskapstyp
Name |
Typ |
Description |
FourCC
|
string
|
Spåra FourCC
|
Unknown
|
string
|
Okänd spåregenskap
|
TrackSelection
Klass för att välja ett spår
Name |
Typ |
Description |
trackSelections
|
TrackPropertyCondition[]
|
TrackSelections är en lista med villkor för spåregenskaper som kan ange spår
|