Skip to content

AppGateway #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Automation/Task6/AppGateway.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#Creates Azure Application Gateway

param (
[Parameter(Mandatory=$true)]
[string]
$applicationGatewayName,

[Parameter(Mandatory=$true)]
[string]
$location,

[Parameter(Mandatory=$true)]
[string]
$backendAddressPools,

[Parameter(Mandatory=$true)]
[string]
$backendHttpSettingsCollection,

[Parameter(Mandatory=$true)]
[string]
$frontendIPConfigurations,

[Parameter(Mandatory=$true)]
[string]
$gatewayIPConfigurations,

[Parameter(Mandatory=$true)]
[string]
$frontendPorts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be comma separation between parameters. This is causing issues while running the script.


[Parameter(Mandatory=$true)]
[string]
$httpListeners
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here


[Parameter(Mandatory=$true)]
[string]
$requestRoutingRules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here


[Parameter(Mandatory=$true)]
[string]
$sku

)

$templateFilePath = "./template.json"

New-AzResourceGroup
-Name myResourceGroupAG `
-Location West US 2 `

New-AzApplicationGateway `
-Name $applicationGatewayName `
-ResourceGroupName myResourceGroupAG `
-TemplateFile $templateFilePath `
-Location $location `
-BackendAddressPools $backendAddressPools `
-BackendHttpSettingsCollection $backendHttpSettingsCollection `
-FrontendIpConfigurations $frontendIPConfigurations `
-GatewayIpConfigurations $gatewayIPConfigurations `
-FrontendPorts $frontendPorts `
-HttpListeners $httpListeners `
-RequestRoutingRules $requestRoutingRules `
-Sku $sku
161 changes: 161 additions & 0 deletions Automation/Task6/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"applicationGatewayName": {
"type": "string"
},
"tier": {
"type": "string"
},
"skuSize": {
"type": "string"
},
"capacity": {
"type": "int",
"defaultValue": 2
},
"subnetName": {
"type": "string"
},
"zones": {
"type": "array"
},
"virtualNetworkName": {
"type": "string"
},
"virtualNetworkPrefix": {
"type": "array"
}
},
"variables": {
"vnetId": "[resourceId('nsc-rg-ag-westus2-thur','Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"publicIPRef": "/subscriptions/9f4dcf43-aa06-457b-b975-f0216baef20d/resourceGroups/loanlpautomationlab01-rg/providers/Microsoft.Network/publicIPAddresses/frondendIP",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"applicationGatewayId": "[resourceId('Microsoft.Network/applicationGateways', parameters('applicationGatewayName'))]"
},
"resources": [
{
"name": "[parameters('applicationGatewayName')]",
"type": "Microsoft.Network/applicationGateways",
"apiVersion": "2019-09-01",
"location": "[parameters('location')]",
"zones": "[parameters('zones')]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
],
"tags": {},
"properties": {
"sku": {
"name": "[parameters('skuSize')]",
"tier": "[parameters('tier')]",
"capacity": "[parameters('capacity')]"
},
"gatewayIPConfigurations": [
{
"name": "appGatewayIpConfig",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"frontendIPConfigurations": [
{
"name": "appGwPublicFrontendIp",
"properties": {
"PublicIPAddress": {
"id": "[variables('publicIPRef')]"
}
}
}
],
"frontendPorts": [
{
"name": "port_80",
"properties": {
"Port": 80
}
}
],
"backendAddressPools": [
{
"name": "nsc_ag_westus2_bp",
"properties": {
"backendAddresses": []
}
}
],
"backendHttpSettingsCollection": [
{
"name": "nsc_ag_westus2_http",
"properties": {
"Port": 80,
"Protocol": "Http",
"cookieBasedAffinity": "Disabled",
"requestTimeout": 20
}
}
],
"httpListeners": [
{
"name": "nsc_ag_westus2_l",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(variables('applicationGatewayId'), '/frontendIPConfigurations/appGwPublicFrontendIp')]"
},
"frontendPort": {
"id": "[concat(variables('applicationGatewayId'), '/frontendPorts/port_80')]"
},
"protocol": "Http",
"sslCertificate": null
}
}
],
"requestRoutingRules": [
{
"Name": "nsc_ag_westus2_rrl",
"properties": {
"RuleType": "Basic",
"httpListener": {
"id": "[concat(variables('applicationGatewayId'), '/httpListeners/nsc_ag_westus2_l')]"
},
"backendAddressPool": {
"id": "[concat(variables('applicationGatewayId'), '/backendAddressPools/nsc_ag_westus2_bp')]"
},
"backendHttpSettings": {
"id": "[concat(variables('applicationGatewayId'), '/backendHttpSettingsCollection/nsc_ag_westus2_http')]"
}
}
}
],
"enableHttp2": false,
"sslCertificates": [],
"probes": []
}
},
{
"apiVersion": "2019-09-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": "[parameters('virtualNetworkPrefix')]"
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "172.19.0.0/24"
}
}
]
}
}
]
}