《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 Application Gateway (4) 设置URL路由 - PowerShell的更多相关文章

  1. Azure Application Gateway (3) 设置URL路由

    <Windows Azure Platform 系列文章目录> 在之前的文章中,笔者介绍了Azure Web App可以设置URL路由.如下图: 在这里笔者简单介绍一下,首先我们还是创建以 ...

  2. Azure Application Gateway (1) 入门

    <Windows Azure Platform 系列文章目录> 请读者注意,Azure Application Gateway在ASM模式下,只能通过PowerShell创建 具体可以参考 ...

  3. Azure Application Gateway(一)对后端 Web App 进行负载均衡

    一,引言 今天,我们学习一个新的知识点-----Azure Application Gateway,通过Azure 应用程序网关为我么后端的服务提供负载均衡的功能.我们再文章头中大概先了解一下什么是应 ...

  4. Azure Application Gateway(二)对后端 VM 进行负载均衡

    一,引言 上一节有讲到使用 Azure Application Gateway 为我们后端类型为 Web App 的 Demo 项目提供负载均衡,Azure Application Gateway 的 ...

  5. Azure Application Gateway (5) Application Gateway SSL Offload配置

    <Windows Azure Platform 系列文章目录> 之前有个客户提出了一个需求,他们的互联网访问的架构分为两种: 1.第一层是使用Azure Application Gatew ...

  6. Azure Application Gateway (2) 面向公网的Application Gateway

    <Windows Azure Platform 系列文章目录> 本章将介绍如何创建面向公网的Application Gateway,我们需要准备以下工作: 1.创建新的Azure Reso ...

  7. Windows Azure支持七层负载均衡--Application Gateway

    一直以来Windows Azure的负载均衡(Loadbalancer)功能一直被客户诟病,无法其竞争对手(特别是国内的云厂商)匹敌. Windows Azure的负载均衡器是四层的,前期的版本不支持 ...

  8. 【Azure 事件中心】为应用程序网关(Application Gateway with WAF) 配置诊断日志,发送到事件中心

    问题描述 在Application Gateway中,开启WAF(Web application firewall)后,现在需要把访问的日志输出到第三方分析代码中进行分析,如何来获取WAF的诊断日志呢 ...

  9. Ionic 动态配置url路由的设置

    随着Ionic App功能的不断增加,需要路由的url设置就越来越多,不喜欢在config函数中写一堆硬代码,一则不美,二则维护起来也麻烦,能不能把这些数据独立出来呢? 经过查找资料与各种实验,最终找 ...

随机推荐

  1. 报文解析及CRC类

    /// <summary> /// 报文解析转换类 /// </summary> public class DatagramConvert { public static En ...

  2. WDM驱动加载方式理解

    当PC得知有新设备插入时,总线驱动会创建相应的物理驱动PDO,然后提示有新设备插入,这时候调用相应Driver的AddDevice方法创建功能驱动FDO 下面是一个典型的AddDevice方法 #pr ...

  3. gitlab使用有感之坚持

    当老师请大二的学弟教我们使用这个软件的时候, 当时就吓坏我了,感觉好高大上的样子,全英文的,还有什么阿里云的服务器用来代码管理:心情一下子就不好了,感觉自己懂得东西好少啊,比学弟懂得都少,跟不上时代的 ...

  4. (翻译)《Hands-on Node.js》—— Why?

    事出有因 为何选择event loop? Event Loop是一种推进无阻塞I/O(网络.文件或跨进程通讯)的软件模式.传统的阻塞编程也是用一样的方式,通过function来调用I/O.但进程会在该 ...

  5. nodejs事件轮询详述

    目录 概述 nodejs特点 事件轮询 关于异步方法 概述 关于nodejs的介绍网上资料非常多,最近由于在整理一些函数式编程的资料时,多次遇到nodejs有关的内容.所以就打算专门写一篇文章总结一下 ...

  6. 微信为什么发布 Mac 版?

    因为 Mac 就是好啊就是好啊,就是好…… 打完收工,谢谢,鼓掌 piapiapia……晚安! 这么写在京城行走会不会挨板砖呢?头像已经印到书上满世界的发出去了,虽然考虑到行走江湖求一个稳字,我还特意 ...

  7. 说说设计模式~大话目录(Design Pattern)

    回到占占推荐博客索引 设计模式(Design pattern)与其它知识不同,它没有华丽的外表,没有吸引人的工具去实现,它是一种心法,一种内功,如果你希望在软件开发领域有一种新的突破,一个质的飞越,那 ...

  8. Linux更改用户密码

    登录虚拟机后,使用passwd密令更改用户密码,新密码需要输入两次才能更改成功.不多说,直接上代码 [root@localhost Desktop]# passwd //使用passwd密令 Chan ...

  9. Hello Blog

    转眼之间,工作已经快五年了. 五年走的时候不觉得,当真正过来了,一回头,才真正体会到什么叫时间匆匆. 做了五年的技术,算是多有波折.想一想,做技术真的挺需要耐得住寂寞的,毕竟花花世界,压力太大,诱惑太 ...

  10. 使用paramiko如何连接服务器?

    本文和大家分享的是python开发中使用paramiko连接服务器的方法和步骤,希望通过本文的,对大家学习和使用paramiko有所帮助. ssh连接步骤 1.ssh server建立server p ...