【问题标题】:"parameters.properties.archiveWindowLength must be a TimeSpan/Duration"“parameters.properties.archiveWindowLength 必须是 TimeSpan/Duration”
【发布时间】:2021-02-08 01:36:36
【问题描述】:

我遇到了上述错误,其完整描述如下:

Error: Error parameters.properties.archiveWindowLength must be a TimeSpan/Duration. occurred in serializing the payload - {
  "archiveWindowLength": "PT30M",
  "assetName": "asset-OBS"
}.

我正在使用 nodeJS,在从 azure 创建实时输出时会出现此错误。

我的代码:

azureMediaServicesClient.liveOutputs.create(resourceGroup, accountName, liveEventName, liveOutputName, {
            archiveWindowLength : "PT30M",
            assetName : assetName,
 })

我试图搜索这个但没有找到任何支持的ans。

  • 我已经尝试过 ms-rest 最新的 2.5.4。
  • 已关注this link。

【问题讨论】:

标签: node.js azure-media-services


【解决方案1】:

官方文档中archiveWindowLength的描述与nodejs sdk不同。我猜可能是nodejs sdk没有及时更新。

最新的官方文档archiveWindowLength是字符串类型,但在nodejs sdk中仍然是moment.duration。你可以看到下面的截图。

所以要修改程序,使用moment.duration,需要通过const moment = require("moment");导入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)
  }
});

它对我有用。

【讨论】:

【解决方案2】:

谢谢大家!谢谢杰森潘。

请注意,这里有一个用于媒体服务的全新 Node.js SDK - https://www.npmjs.com/package/@azure/arm-mediaservices

我没有时间构建任何新的实时流媒体示例,但我开始检查一些新的编码示例,以展示如何使用更新的 SDK。 很高兴在这个 repo 中获得社区对样本的任何支持!请让我知道您想贡献哪些内容。
https://github.com/Azure-Samples/media-services-v3-node-tutorials/tree/master

我现在在这里有这个分支,用于处理一些新样本。请注意,目前仅更新了 HelloWorld-listAssets 和 StreamFilesSample。 https://github.com/Azure-Samples/media-services-v3-node-tutorials/tree/updatedNodeSDK

更新: 我使用最新的 Nodejs SDK for Media Services 在 Typescript 中创建了新示例。看这里 https://github.com/Azure-Samples/media-services-v3-node-tutorials

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2011-01-19
  • 2018-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-07
  • 2019-03-21
相关资源
最近更新 更多