edit-icon download-icon


Last Updated: Mar 20, 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.


  • 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. #include <iostream>
  2. #include <alibabacloud/core/AlibabaCloud.h>
  3. #include <alibabacloud/cdn/CdnClient.h>
  4. using namespace AlibabaCloud;
  5. using namespace AlibabaCloud::Cdn;
  6. int main(int argc, char** argv)
  7. {
  8. // Initialize the SDK
  9. AlibabaCloud::InitializeSdk();
  10. // Create a client instance
  11. ClientConfiguration configuration("<your-region-id>");
  12. CdnClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
  13. // Create a request and set parameters
  14. Model::AddCdnDomainRequest request;
  15. request.setCdnType("web");
  16. request.setDomainName("test.com");
  17. request.setSources("test.com");
  18. request.setSourceType("domain");
  19. // Initiate the request
  20. auto outcome = client.addCdnDomain(request);
  21. if(outcome.isSuccess())
  22. std::cout << "Success" << std::endl;
  23. // Close the SDK
  24. AlibabaCloud::ShutdownSdk();
  25. return 0;
  26. }
Thank you! We've received your feedback.