@zhouyy
2018-03-16T06:55:41.000000Z
字数 5853
阅读 666
azure
Application Setting-> General settings
PS C:\Users\Administrator.USER-20170626GN> $wsNameyy-test-webPS C:\Users\Administrator.USER-20170626GN> Set-AzureWebsite $wsName -WebSocketsEnabled $true
app settings can be anything, such as URL to a websevice
app settings and connection string 都可以被app 以环境变量的方式获得
环境变量构造:
- Name of environment var = constant str + key name
for connstr:
=SQLAZURECONNSTR_/SQLCONNSTR_/MYSQLCONNSTR_/CUSTOMECONNSTR_ + testAppConnStr
=SQLAZURECONNSTR_testAppConnStr
for app setting:
= constant str + key name
=APPSETTING_+webServiceURL
PS C:\Users\Administrator.USER-20170626GN> $settings = New-Object HashtablePS C:\Users\Administrator.USER-20170626GN> $settings["YY-test-web-hr-url"]= "https://yy-test-web/hr"PS C:\Users\Administrator.USER-20170626GN> Set-AzureWebsite -Name $wsName -AppSettings $settings
option 1: store a connection string as a site setting
option 2: store the settings in app configure file like Web.config 、Php.ini
option 1 is preferred. app 可以在运行时作为环境变量获取 connection string, 这样做更加安全,避免了在app 配置文件中存储敏感信息。
Support:
SQL DATABASE-Azure SQL DB
SQL SERVER- 本地或虚拟机中的sql server
MYSQL
CUSTOM-其他nosql
PS:
以k/v的形式被存储
Key = "testAppConnStr"Value = "Server=tcp: ;Database= ;User ID= "
@{} hash k/v
PS C:\Users\Administrator.USER-20170626GN> $connStrs = (@{Name="yytestwebdb"; Type ="SQLAzure"; ConnectionString="Server=tcp:foodsafety.database.chinacloudapi.cn,1433;Initial Catalog=food-trace"})PS C:\Users\Administrator.USER-20170626GN> Set-AzureWebsite -Name $wsName -ConnectionStrings $connStrs
XX.azurewebsite.net(default)->XX.com.
Attention:Custom DNS is not supported in the Free tier. +
步骤:
1、在域名注册商(domain registar)处获取域名
2、在域名注册商(domain registar)处 为域名添加 DNS 记录
3、将特定域名与Azure 网站相关联
1、A record
A (Address) 记录是用来指定主机名(或域名)对应的IP地址记录。用户可以将该域名下的网站服务器指向到自己的web server上。同时也可以设置您域名的二级域名。在Azure website中, IP不是某个VM的IP,而是网站运行的服务器集群的IP。
如何获取IP:Custom Domain->External IP address
To map an A record to an app, App Service requires two DNS records:
<app_name>.azurewebsites.net. to verify that you own the custom domain.| Type | Name | Value |
|---|---|---|
| A | xx.com | IP addr: 10.200.XX.XX |
| TXT | xx.com | <app_name>.azurewebsites.net |
TXT: 记录,一般指为某个主机名或域名设置的说
2、CANME record
CANME : 别名记录。这种记录允许您将多个名字映射到另外一个域名
Add a CNAME record to map a subdomain to the app's default hostname <app_name>.azurewebsites.net
Set-AzureWebsite -Name $wsName -HostName @(www.XX.com,"XX.com")
Must be Standard. Custom SSL is not supported in the Free or Shared tier
wildcard certificate :
通配型证书(wildcard certificate)是在一个域及其所有子域上应用的数字证书。
步骤:
1、获得SSL证书
2、上传证书到Azure
3、绑定
SSL证书需要满足以下要求:
1、有私钥
2、可被转换为 .pfx格式(Personal Information Exchange)
3、证书的主体名字与custom域名一致。多个custom 域名,则需要共享证书,使用 wildcard certificate or subject alternative name
4、需要使用 2048-bit以上加密
Portal:
SSL Certificates
->Import or Upload
->Binding
Server Name Indication (SNI) or IP based SSL
1、如果使用IP based SSL,custom IP 使用A record 配置,Azure会为你的网站分配新的IP地址,因此需要在域名注册商处更新A record 的IP
2、基于 SNI 的 SSL 适用于新式浏览器,而基于 IP 的 SSL 适用于所有浏览器。
Azure Traffic Manager
Network service that route user to websites deployment in potentially different DCs in the world
步骤:
1、创建 Azure Traffic Manager Profile
2、添加 endpoint 到 profile
3、更新 custom domian的 DNS record
All ATM profile use shared domian *.trafficmanager.net->yourdomianname.trafficmanager.net
DNS Time-to-live (TTL), tells DNS clients how long to cache the name resolved by ATM.
Create a Traffic Manager profile to define the routing method used to distribute user traffic to service endpoints in different datacenters. Traffic Manager endpoints can be Azure virtual machines, web apps, cloud services, and external non-Azure endpoints.
Distribute traffic to your endpoints:
排序方式
https://docs.microsoft.com/en-us/azure/traffic-manager/traffic-manager-routing-methods
portal:
New > Networking > See all, click Traffic Manager profile to open the Create Traffic Manager profile blade, then click Create.
PS:
New-AzureTrafficManagerProfile -Name $wsName `-DomianName yy-test-web.trafficmanager.net -RoutingMethod Geographic
Must be Standard mode
Portal:
1、In the Traffic Manager profile blade, in the Settings section, click Endpoints.
2、In the Endpoints blade that is displayed, click Add

PS:
$tmProfile=Get-AzureTrafficManagerProfile -Name $wsNameAdd-AzureTrafficManagerEndpoint -TrafficManagerProfile $tmProfile `-DomianName "yy-test-web.trafficmanager.net" `-Type "Azure endpoint" -Name yy-test - Target resource "" -Priority 1 | `Set-AzureTrafficManagerProfile
update custom domain to point to ATM DNS using CNAME
| Type | Name | Value |
|---|---|---|
| CNAME | youdomairname.com | youdomainname.trafficmanager.net |
处理器映射(handler mapping)
HandlerMapping是把一个URL指定到一个Controller.通过处理器映射,你可以将web请求映射到正确的处理器(handler)上。
Portal:
> Appication Settings
PS:
$HandlerMapping = New-Object Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.HandlerMapping$HandlerMapping.Extension = "*.php"$HandlerMapping.ScriptProcessor="d:\\\"Set-AzureWebsite -Name $wsName -HandlerMappings $handlerMapping
Portal:
> Appication Settings
vitual directory
pyhsical directory