以编程方式将域名添加到Azure网站 [英] Programmatically add domain name to azure website

查看:42
本文介绍了以编程方式将域名添加到Azure网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在1500以上的域名上运行的Web应用程序.

I have a web application that runs on 1500+ on domain names.

每个页面加载都将运行Request.ServerVariables ["SERVER_NAME"]以标识正在使用的域名,然后根据该域名返回内容.

Each page load will run Request.ServerVariables["SERVER_NAME"] to identify which domain name is being used and then return the content based on this domain name.

我们正在使用Azure网站来运行该应用程序.

We are using Azure Websites to run the application.

我希望能够在我们获得新客户时以编程方式添加新域名,最好是通过API.

I would like to be able to programmatically add new domain names when we get new clients, ideally through an API.

推荐答案

我找到了答案:

ARM API调用如下:

The ARM API calls would be like below:

https://management.azure.com/subscriptions/{subscriptionID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Web/sites/{WebSiteName}?api-version=2014-06-01

Content-Type: application/json

{
  "location": "<REGION_NAME>",
  "properties": {
    "hostNames": [
      "*.azurewebsites.net",
      "customdomain1",
      "customdomain2"
    ]
  }
}

< REGION_NAME> -该网站的ENVIRONMENT变量中可用

<REGION_NAME> - available in ENVIRONMENT variables for the site

还可以在SCM网站 https://[websitename] .scm.azurewebsites中检查该值.net/Env

这篇关于以编程方式将域名添加到Azure网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆