In this article:
Update an Track
Updates an existing Track in the asset
PATCH https://{{api-endpoint}}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}?api-version={{api-version}}
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
accountName |
path | True | string | The Media Services account name. |
assetName |
path | True | string | The Asset name. |
resourceGroupName |
path | True | string | The name of the resource group within the Azure subscription. |
subscriptionId |
path | True | string | The unique identifier for a Microsoft Azure subscription. |
trackName |
path | True | string | The Asset Track name. |
api-version |
query | True | string | The version of the API to be used with the client request. |
Request Body
Name | Type | Description |
---|---|---|
properties.track | TrackBase: AudioTrack VideoTrack TextTrack |
Detailed information about a track in the asset. |
Responses
Name | Type | Description |
---|---|---|
202 Accepted | AssetTrack |
Accepted Headers Retry-After: integer |
Other Status Codes | ErrorResponse | Detailed error information. |
Examples
Update a Track
Technology | Sample request |
---|---|
HTTP |
PATCH https://{{api-endpoint}}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/assets/ClimbingMountRainer/tracks/text1?api-version={{api-version}} { "properties": { "track": { "@odata.type": "#Microsoft.Media.TextTrack", "displayName": "A new name" } } } |
Java |
import com.azure.resourcemanager.mediaservices.models.AssetTrack; import com.azure.resourcemanager.mediaservices.models.TextTrack; /** * Samples for Tracks Update. */ public final class Main { /* * x-ms-original-file: * specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks- * update.json */ /** * Sample code: Update a Track. * * @param manager Entry point to MediaServicesManager. */ public static void updateATrack(com.azure.resourcemanager.mediaservices.MediaServicesManager manager) { AssetTrack resource = manager.tracks().getWithResponse("contosorg", "contosomedia", "ClimbingMountRainer", "text1", com.azure.core.util.Context.NONE).getValue(); resource.update().withTrack(new TextTrack().withDisplayName("A new name")).apply(); } }} To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue. |
Python |
from azure.identity import DefaultAzureCredential from azure.mgmt.media import AzureMediaServices """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-media # USAGE python assettracksupdate.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.tracks.begin_update( resource_group_name="contoso", account_name="contosomedia", asset_name="ClimbingMountRainer", track_name="text1", parameters={ "properties": {"track": {"@odata.type": "#Microsoft.Media.TextTrack", "displayName": "A new name"}} }, ).result() print(response) # x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-update.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. |
Go |
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/asset-tracks-update.json func ExampleTracksClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armmediaservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewTracksClient().BeginUpdate(ctx, "contoso", "contosomedia", "ClimbingMountRainer", "text1", armmediaservices.AssetTrack{ Properties: &armmediaservices.AssetTrackProperties{ Track: &armmediaservices.TextTrack{ ODataType: to.Ptr("#Microsoft.Media.TextTrack"), DisplayName: to.Ptr("A new name"), }, }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %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. |
JavaScript |
const { AzureMediaServices } = require("@azure/arm-mediaservices"); const { DefaultAzureCredential } = require("@azure/identity"); /** * This sample demonstrates how to Updates an existing Track in the asset * * @summary Updates an existing Track in the asset * x-ms-original-file: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2022-08-01/examples/asset-tracks-update.json */ async function updateATrack() { const subscriptionId = process.env["MEDIASERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; const resourceGroupName = process.env["MEDIASERVICES_RESOURCE_GROUP"] || "contoso"; const accountName = "contosomedia"; const assetName = "ClimbingMountRainer"; const trackName = "text1"; const parameters = { track: { odataType: "#Microsoft.Media.TextTrack", displayName: "A new name", }, }; const credential = new DefaultAzureCredential(); const client = new AzureMediaServices(credential, subscriptionId); const result = await client.tracks.beginUpdateAndWait( resourceGroupName, accountName, assetName, trackName, 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. |
.NET |
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/asset-tracks-update.json // this example is just showing the usage of "Tracks_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); // this example assumes you already have this MediaAssetTrackResource created on azure // for more information of creating MediaAssetTrackResource, please refer to the document of MediaAssetTrackResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "contoso"; string accountName = "contosomedia"; string assetName = "ClimbingMountRainer"; string trackName = "text1"; ResourceIdentifier mediaAssetTrackResourceId = MediaAssetTrackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, assetName, trackName); MediaAssetTrackResource mediaAssetTrack = client.GetMediaAssetTrackResource(mediaAssetTrackResourceId); // invoke the operation MediaAssetTrackData data = new MediaAssetTrackData() { Track = new TextTrack() { DisplayName = "A new name", }, }; ArmOperation lro = await mediaAssetTrack.UpdateAsync(WaitUntil.Completed, data); MediaAssetTrackResource 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 MediaAssetTrackData 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. |
Sample response
Status code: 202
HTTP
azure-asyncoperation: https://{{api-endpoint}}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Media/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/assets/ClimbingMountRainer/tracks/text3/operationStatuses/62e4d893-d233-4005-988e-a428d9f77076?api-version={{api-version}} location: https://{{api-endpoint}}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Media/resourceGroups/contosorg/providers/Microsoft.Media/mediaServices/contosomedia/assets/ClimbingMountRainer/tracks/text3/operationResults/62e4d893-d233-4005-988e-a428d9f77076?api-version={{api-version}}
JSON
{ "name": "text1", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Media/mediaservices/contosomedia/assets/ClimbingMountRainer/tracks/text1", "type": "Microsoft.Media/mediaservices/assets/tracks", "properties": { "track": { "@odata.type": "#Microsoft.Media.TextTrack", "fileName": "auto_generated.ttml", "displayName": "A new name", "languageCode": "en-us", "playerVisibility": "Visible" }, "provisioningState": "InProgress" } }
Definitions
Name | Description |
---|---|
AssetTrack | An Asset Track resource. |
AudioTrack | Represents an audio track in the asset. |
DashSettings | The DASH setting for a track. |
ErrorAdditionalInfo | The resource management error additional info. |
ErrorDetail | The error detail. |
ErrorResponse | Error response. |
HlsSettings | The HLS setting for a track. |
Provisioning State | Provisioning state of the asset track. |
TextTrack | Represents a text track in an asset. A text track is usually used for sparse data related to the audio or video tracks. |
VideoTrack | Represents a video track in the asset. |
Visibility | When PlayerVisibility is set to "Visible", the text track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to "Hidden", the text will not be available to the client. The default value is "Visible". |
AssetTrack
Name | Type | Description |
---|---|---|
id | string |
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/ |
name | string | The name of the resource. |
properties.provisioningState | Provisioning state of the asset track. | |
properties.track | TrackBase: AudioTrack TextTrack VideoTrack |
Detailed information about a track in the asset. |
type | string | The type of the resource, e.g., "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". |
AudioTrack
Represents an audio track in the asset.
Name | Type | Description |
---|---|---|
@odata.type |
string: #Microsoft. Media.Audio Track |
The discriminator for derived types. |
bitRate | integer | The stream bit rate for the audio track. |
dashSettings | DashSettings | The DASH specific setting for the audio track. |
displayName | string | The display name of the audio track on a video player. In HLS, this maps to the NAME attribute of EXT-X-MEDIA. |
fileName | string | The file name to the source file. This file is located in the storage container of the asset. |
hlsSettings | HlsSettings | The HLS specific setting for the audio track. |
languageCode | string | The RFC5646 language code for the audio track. |
mpeg4TrackId | integer | The MPEG-4 audio track ID for the audio track. |
DashSettings
Name | Type | Description |
---|---|---|
role | string | The role for the DASH setting. |
ErrorAdditionalInfo
The resource management error additional info.
Name | Type | Description |
---|---|---|
info | object | The additional info. |
type | string | The additional info type. |
ErrorDetail
Name | Type | Description |
---|---|---|
additionalInfo | ErrorAdditionalInfo | The error additional info. |
code | string | The error code. |
details | ErrorDetail | The error details. |
message | string | The error message. |
target | string | The error target. |
ErrorResponse
Name | Type | Description |
---|---|---|
error | ErrorDetail | The error object. |
HlsSettings
Name | Type | Description |
---|---|---|
characteristics | string | The characteristics for the HLS setting. |
default | boolean | The default for the HLS setting. |
forced | boolean | The forced for the HLS setting. |
ProvisioningState
Name | Type | Description |
---|---|---|
Failed | string | Provisioning state failed. |
InProgress | string | Provisioning state in progress. |
Succeeded | string | Provisioning state succeeded. |
TextTrack
Represents a text track in an asset. A text track is usually used for sparse data related to the audio or video tracks.
Name | Type | Description |
---|---|---|
@odata.type |
string: #Microsoft. Media.Audio Track |
The discriminator for derived types. |
displayName | string | The display name of the audio track on a video player. In HLS, this maps to the NAME attribute of EXT-X-MEDIA. |
fileName | string | The file name to the source file. This file is located in the storage container of the asset. |
hlsSettings | HlsSettings | The HLS specific setting for the audio track. |
languageCode | string | The RFC5646 language code for the audio track. |
playerVisibility | Visibility | When PlayerVisibility is set to "Visible", the text track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to "Hidden", the text will not be available to the client. The default value is "Visible". |
VideoTrack
Represents a video track in the asset.
Name | Type | Description |
---|---|---|
@odata.type |
string: #Microsoft. Media.Audio Track |
The discriminator for derived types. |
Visibility
When PlayerVisibility is set to "Visible", the text track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to "Hidden", the text will not be available to the client. The default value is "Visible".
Name | Type | Description |
---|---|---|
Hidden | string | The track is hidden to video player. |
Visible | string | The track is visible to video player. |