Azure Application Gateway (4) 设置URL路由 - PowerShell

简介:

 《Windows Azure Platform 系列文章目录

 

  本文将介绍如果使用Azure PowerShell,创建Azure Application Gateway URL Routing

  请读者在使用之前,请先查看笔者之前的文章:Azure Application Gateway (3) 设置URL路由,熟悉相关的内容

 

  注意:Azure Application Gateway必须在ARM模式下才可以创建。

  另外PowerShell模式下,和Portal创建的不一样。

  PowerShell模式,并不需要先创建81端口,再创建80端口。PowerShell直接可以使用80端口设置URL Routing

复制代码
#在弹出窗口登录
Login-AzureRmAccount -EnvironmentName AzureChinaCloud

#选择订阅信息
Select-AzureRmSubscription -SubscriptionName "Training"

#先手动创建Resource Group,这里设置Resource Group
$resourcegroupname = 'LeiAppGWRG'

#手动创建Virtual Network
#同之前的文档一样,这个Virtual Network必须要有2个Subnet
$virtualnetworkname= 'LeiAppGatewayVNet'

#设置Application Gateway名称
$appgatewayname = 'LeiAppGateway'

#设置Application Gateway公网IP地址
$publicipname = 'LeiAppGatewayPublicIP'

#Application Gateway 所在的数据中心
$location= 'China East'

#设置端口号
$port=80

$vnet=Get-AzureRmVirtualNetwork -name $virtualnetworkname -ResourceGroupName $resourcegroupname

#Application Gateway加入到第2个Subnet里
$subnet=$vnet.Subnets[1]

$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $resourcegroupname -name $publicipname -location $location -AllocationMethod Dynamic

#Create Application Gateway
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name LeiAppGatewayPublicIP -Subnet $subnet

#设置Backend Pool 1
$pool1 = New-AzureRmApplicationGatewayBackendAddressPool -Name imagesBackendPool -BackendIPAddresses 10.0.0.4,10.0.0.5

#设置Backend Pool 2
$pool2 = New-AzureRmApplicationGatewayBackendAddressPool -Name videosBackendPool -BackendIPAddresses 10.0.0.11,10.0.0.12

#设置Backend Pool 1的会话保持,不保持会话
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name "imagesSetting" -Port $port -Protocol Http -CookieBasedAffinity Disabled -RequestTimeout 120

#设置Backend Pool 2的会话保持,为保持会话
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name "videosSetting" -Port $port -Protocol Http -CookieBasedAffinity Enabled -RequestTimeout 240

$fipconfig01 = New-AzureRmApplicationGatewayFrontendIPConfig -Name "frontend1" -PublicIPAddress $publicip

$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name "fep01" -Port $port

$listener = New-AzureRmApplicationGatewayHttpListener -Name "listener01" -Protocol Http -FrontendIPConfiguration $fipconfig01 -FrontendPort $fp01

#设置URL Route,为/images/*
$imagePathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name "pathrule1" -Paths "/images/*" -BackendAddressPool $pool1 -BackendHttpSettings $poolSetting01

#设置URL Route,为/videos/*
$videoPathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name "pathrule2" -Paths "/videos/*" -BackendAddressPool $pool2 -BackendHttpSettings $poolSetting02

#设置DefaultBackendAddressPool
$urlPathMap = New-AzureRmApplicationGatewayUrlPathMapConfig -Name "urlpathmap" -PathRules $videoPathRule, $imagePathRule -DefaultBackendAddressPool $pool1 -DefaultBackendHttpSettings $poolSetting02

$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name "rule1" -RuleType PathBasedRouting -HttpListener $listener -UrlPathMap $urlPathMap

#设置Application Gateway Size为Small,实例个数为1个
$sku = New-AzureRmApplicationGatewaySku -Name "Standard_Small" -Tier Standard -Capacity 1

#开始创建Application Gateway
$appgw = New-AzureRmApplicationGateway -Name $appgatewayname -ResourceGroupName $resourcegroupname  -Location $location -BackendAddressPools $pool1,$pool2 -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01 -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01 -HttpListeners $listener -UrlPathMaps $urlPathMap -RequestRoutingRules $rule01 -Sku $sku
复制代码

 


本文转自Azure Lei Zhang博客园博客,原文链接:http://www.cnblogs.com/threestone/p/6225961.html,如需转载请自行联系原作者


目录
相关文章
|
3月前
|
测试技术
Cypress如何设置全局URL?
Cypress如何设置全局URL?
|
17天前
【超实用】Angular如何修改当前页面网页浏览器url后面?param1=xxx&param2=xxx参数(多用于通过浏览器地址参数保存用户当前操作状态的需求),实现监听url路由切换、状态变化。
【超实用】Angular如何修改当前页面网页浏览器url后面?param1=xxx&param2=xxx参数(多用于通过浏览器地址参数保存用户当前操作状态的需求),实现监听url路由切换、状态变化。
|
4月前
【超实用】Angular如何修改当前页面网页浏览器url后面?param1=xxx&param2=xxx参数(多用于通过浏览器地址参数保存用户当前操作状态的需求),实现监听url路由切换、状态变化。
【超实用】Angular如何修改当前页面网页浏览器url后面?param1=xxx&param2=xxx参数(多用于通过浏览器地址参数保存用户当前操作状态的需求),实现监听url路由切换、状态变化。
【超实用】Angular如何修改当前页面网页浏览器url后面?param1=xxx&param2=xxx参数(多用于通过浏览器地址参数保存用户当前操作状态的需求),实现监听url路由切换、状态变化。
|
3月前
|
前端开发
vue-element-admin最新版4.4实现多个url路由匹配到一个路径时,左侧菜单保持高亮状态
vue-element-admin最新版4.4实现多个url路由匹配到一个路径时,左侧菜单保持高亮状态
29 0
|
3月前
|
前端开发
如何让url在新页面打开路由页面,并脱离vue-admin-template的壳,即不包裹在侧边栏和顶栏中
如何让url在新页面打开路由页面,并脱离vue-admin-template的壳,即不包裹在侧边栏和顶栏中
24 0
|
3月前
|
网络架构
Gateway路由
Gateway路由
宜搭详情页面URL设置
宜搭自定义详情页跳转问题
宜搭详情页面URL设置
|
5月前
|
负载均衡 Java Nacos
Nacos和GateWay路由转发NotFoundException: 503 SERVICE_UNAVAILABLE “Unable to find
Nacos和GateWay路由转发NotFoundException: 503 SERVICE_UNAVAILABLE “Unable to find
144 0
|
6月前
|
监控
gateway 这样设置报错503 ,如何优化参数
当使用Hystrix时,根据您的错误信息,您可能需要调整一些参数来优化性能和解决503错误。以下是一些建议: 1. 调整`semaphore.maxConcurrentRequests`参数:这是控制允许并发请求的最大数量。检查您的应用程序负载和系统资源,并将其适当调整为适合您的情况。如果并发请求量很大,您可能需要增加该值。 2. 调整`timeoutInMilliseconds`参数:这是设置Hystrix命令的超时时间。如果您的服务响应时间很长,您可能需要增加该值以避免超时。确保将超时时间设置为适当的值,以便允许足够的时间来完成请求。 3. 调整`circuitBreaker.sle
100 0
|
7月前
|
机器人 SEO
SAP 电商云 Spartacus UI 根据 url 设置 site context 的具体例子
SAP 电商云 Spartacus UI 根据 url 设置 site context 的具体例子
54 0

热门文章

最新文章