標籤:back -name power enabled cti video 連接埠號碼 選擇 shell
《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