I am having the above error whose full description is as follow:
Error: Error parameters.properties.archiveWindowLength must be a TimeSpan/Duration. occurred in serializing the payload - {
"archiveWindowLength": "PT30M",
"assetName": "asset-OBS"
}.
I am using nodeJS, while creating live output from azure it make this error.
My code for this:
azureMediaServicesClient.liveOutputs.create(resourceGroup, accountName, liveEventName, liveOutputName, {
archiveWindowLength : "PT30M",
assetName : assetName,
})
I have tried to search on this but not found any ans which supports.
The description of archiveWindowLength in the official document and nodejs sdk is different. I guess it may be that nodejs sdk is not updated in time.
The latest official document archiveWindowLength is of string type, but it is still moment.duration in nodejs sdk. You can see the screenshot below.
So to modify the program, use moment.duration
, you need to import moment
through const moment = require("moment");
.
const {AzureMediaServices} = require('azure-arm-mediaservices');
const msRestAzure = require('ms-rest-azure');
const msRest = require('ms-rest');
const azureStorage = require('azure-storage');
const moment = require("moment");
// endpoint config
// make sure your URL values end with '/'
const armAadAudience = "https://management.core.windows.net/";
const aadEndpoint = "https://login.microsoftonline.com/";
const armEndpoint = "";
const subscriptionId = "";
const accountName ="";
const location ="";
const aadClientId = "";
const aadSecret ="";
const aadTenantId ="";
const resourceGroup ="";
msRestAzure.loginWithServicePrincipalSecret(aadClientId, aadSecret, aadTenantId, {
environment: {
activeDirectoryResourceId: armAadAudience,
resourceManagerEndpointUrl: armEndpoint,
activeDirectoryEndpointUrl: aadEndpoint
}
}, async function(err, credentials, subscriptions) {
if (err) return console.log(err);
const azureMediaServicesClient = new AzureMediaServices(credentials, subscriptionId, armEndpoint, { noRetryPolicy: true });
try {
var a= await azureMediaServicesClient.liveOutputs.create(resourceGroup, accountName, "jasonlive", "jasonliveoutput", {
"archiveWindowLength" : moment.duration("PT30M"),
"assetName" : "b-mp4-20210108-153238"
})
console.log(a)
}
catch(e){
console.log(e.message)
}
});
It works for me.