中国Azure媒体服务RESTAPI的Endpoint


 

由于海外Azure和中国Azure有不同的domain,很多用户在使用媒体服务RESTAPI时,需要指定中国Azure媒体服务的Endpoint。本篇文章主要介绍,如何快速查找中国媒体服务的Endpoint:

  1. 登陆中国Azure的门户,进入媒体服务账号的页面,并点击“以编程方式上载视频”

           

    2. 如下示例代码为中黄线的部分为中国Azure媒体服务的上海的Endpoint

        

// Create a .NET console app
// Set the project properties to use the full .NET Framework (not Client Profile)
// With NuGet Package Manager, install windowsazure.mediaservices
// add: using Microsoft.WindowsAzure.MediaServices.Client;
var uploadFilePath = @"YOUR FILE PATH";
// For hitting the Shanghai API endpoint, use "https://wamsshaclus001rest-hs.chinacloudapp.cn/API/", for Beijing use "https://wamsbjbclus001rest-hs.chinacloudapp.cn/API/"
var context = new CloudMediaContext(
new Uri("https://wamsshaclus001rest-hs.chinacloudapp.cn/API/"),
"Your storage account",
"Your storage account key",
"urn:WindowsAzureMediaServices",
"https://wamsprodglobal001acs.accesscontrol.chinacloudapi.cn");
var uploadAsset = context.Assets.Create(Path.GetFileNameWithoutExtension(uploadFilePath), AssetCreationOptions.None);
var assetFile = uploadAsset.AssetFiles.Create(Path.GetFileName(uploadFilePath));
assetFile.Upload(uploadFilePath);


 

   3. 总结Azure媒体服务中国北部和中国东部的Endpoint信息如下:

中国东部 AMS API Server:

https://wamsshaclus001rest-hs.chinacloudapp.cn/API/

中国北部 AMS API Server:

https://wamsbjbclus001rest-hs.chinacloudapp.cn/API/

ACSBaseAddress:

https://wamsprodglobal001acs.accesscontrol.chinacloudapi.cn

 

备注:CloudMediaContext的定义如下:

public CloudMediaContext(Uri apiServer,
string accountName, string accountKey, string scope, string acsBaseAddress)

具体源代码请参考如下github链接:https://github.com/Azure/azure-content/blob/master/articles/media-services-dotnet-connect_programmatically.md

 

Skip to main content