【发布时间】:2015-12-19 19:08:26
【问题描述】:
我的网站托管为 Azure 网站,我需要允许用户创建自己的子域。
我已经使用 DNS 和 CNAME 选项在本地机器上实现了这个,但我不能在 Azure 中做到这一点。当我尝试为站点添加 Azure 主机名时,我收到主机名必须以“.azurewebsites.net”结尾的错误。
这是我的代码:
var client = new WebSiteManagementClient(new CertificateCloudCredentials(ConfigurationManager.AppSettings["AzureSubscriptionId"],
new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, "{certificate}"), "{password}")));
var configuration = client.WebSites.Get(webSpaceName, webSiteName, new WebSiteGetParameters());
if (configuration.StatusCode != HttpStatusCode.OK)
throw new Exception("AzureGet: " + subdomain);
configuration.WebSite.HostNames.Add(hostName);
var response = client.WebSites.Update(webSpaceName, webSiteName, new WebSiteUpdateParameters());
是否有任何其他方法可以添加自定义主机名,例如“sub.mydomain.net”?
【问题讨论】:
标签: c# azure dns azure-web-app-service hostname