edit-icon download-icon

CDN

Last Updated: Mar 21, 2018

Alibaba Cloud Content Delivery Network (CDN), is a distributed network built on, and overlaying, the bearer network, and is composed of edge node server clusters distributed across different regions. For more information, see CDN documentation.

This tutorial uses the AddCdnDomain API of CDN to show you how to add a CDN domain.

Prerequisites

  • Before creating a CDN domain, you must have activated the CDN service.

  • The CDN domain name must already have been filed.

  • If the origin site content is not on the Alibaba Cloud platform, it must be reviewed. The review will be completed before the next business day.

  • Make sure you have set up credentials and the endpoint. For more information, see Set up credentials and Set service endpoints.

Code example

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Profile;
  4. using Aliyun.Acs.Core.Exceptions;
  5. using Aliyun.Acs.Cdn.Model.V20141111;
  6. class Sample
  7. {
  8. static void Main(string[] args)
  9. {
  10. // Create a client instance
  11. IClientProfile clientProfile = DefaultProfile.GetProfile("<your-region-id>", "<your-access-key-id>", "<your-access-key-secret>");
  12. DefaultAcsClient client = new DefaultAcsClient(clientProfile);
  13. try
  14. {
  15. // Create a request and set parameters
  16. AddCdnDomainRequest request = new AddCdnDomainRequest();
  17. request.CdnType = "web";
  18. request.DomainName = "test.com";
  19. request.Sources = "test.com";
  20. request.SourceType = "domain";
  21. // Initiate the request
  22. AddCdnDomainResponse response = client.GetAcsResponse(request);
  23. Console.WriteLine("Success");
  24. }
  25. catch (ServerException e)
  26. {
  27. Console.WriteLine(e.ErrorCode);
  28. Console.WriteLine(e.ErrorMessage);
  29. }
  30. catch (ClientException e)
  31. {
  32. Console.WriteLine(e.ErrorCode);
  33. Console.WriteLine(e.ErrorMessage);
  34. }
  35. }
  36. }
Thank you! We've received your feedback.