-
Notifications
You must be signed in to change notification settings - Fork 423
/
client.go
636 lines (567 loc) · 21 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
// -------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// --------------------------------------------------------------------------------------------
package azure
import (
"context"
"encoding/json"
"fmt"
"time"
r "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources"
n "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-03-01/network"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure/auth"
"k8s.io/klog/v2"
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/controllererrors"
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/utils"
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/version"
)
// AzClient is an interface for client to Azure
type AzClient interface {
SetAuthorizer(authorizer autorest.Authorizer)
SetSender(sender autorest.Sender)
SetDuration(retryDuration time.Duration)
ApplyRouteTable(string, string) error
WaitForGetAccessOnGateway(maxRetryCount int) error
GetGateway() (n.ApplicationGateway, error)
UpdateGateway(*n.ApplicationGateway) error
DeployGatewayWithVnet(ResourceGroup, ResourceName, ResourceName, string, string) error
DeployGatewayWithSubnet(string, string) error
GetSubnet(string) (n.Subnet, error)
GetPublicIP(string) (n.PublicIPAddress, error)
}
type azClient struct {
appGatewaysClient n.ApplicationGatewaysClient
publicIPsClient n.PublicIPAddressesClient
virtualNetworksClient n.VirtualNetworksClient
subnetsClient n.SubnetsClient
routeTablesClient n.RouteTablesClient
groupsClient r.GroupsClient
deploymentsClient r.DeploymentsClient
clientID string
subscriptionID SubscriptionID
resourceGroupName ResourceGroup
appGwName ResourceName
memoizedIPs map[string]n.PublicIPAddress
ctx context.Context
}
// NewAzClient returns an Azure Client
func NewAzClient(subscriptionID SubscriptionID, resourceGroupName ResourceGroup, appGwName ResourceName, uniqueUserAgentSuffix, clientID string) AzClient {
settings, err := auth.GetSettingsFromEnvironment()
if err != nil {
return nil
}
userAgent := fmt.Sprintf("ingress-appgw/%s/%s", version.Version, uniqueUserAgentSuffix)
az := &azClient{
appGatewaysClient: n.NewApplicationGatewaysClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
publicIPsClient: n.NewPublicIPAddressesClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
virtualNetworksClient: n.NewVirtualNetworksClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
subnetsClient: n.NewSubnetsClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
routeTablesClient: n.NewRouteTablesClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
groupsClient: r.NewGroupsClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
deploymentsClient: r.NewDeploymentsClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
clientID: clientID,
subscriptionID: subscriptionID,
resourceGroupName: resourceGroupName,
appGwName: appGwName,
memoizedIPs: make(map[string]n.PublicIPAddress),
ctx: context.Background(),
}
if err := az.appGatewaysClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to App Gateway client: ", userAgent)
}
if err := az.publicIPsClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to Public IP client: ", userAgent)
}
if err := az.virtualNetworksClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to Virtual Networks client: ", userAgent)
}
if err := az.subnetsClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to Subnets client: ", userAgent)
}
if err := az.routeTablesClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to Route Tables client: ", userAgent)
}
if err := az.groupsClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to Groups client: ", userAgent)
}
if err := az.deploymentsClient.AddToUserAgent(userAgent); err != nil {
klog.Error("Error adding User Agent to Deployments client: ", userAgent)
}
// increase the polling duration to 60 minutes
az.appGatewaysClient.PollingDuration = 60 * time.Minute
az.deploymentsClient.PollingDuration = 60 * time.Minute
return az
}
func (az *azClient) SetAuthorizer(authorizer autorest.Authorizer) {
az.appGatewaysClient.Authorizer = authorizer
az.publicIPsClient.Authorizer = authorizer
az.virtualNetworksClient.Authorizer = authorizer
az.subnetsClient.Authorizer = authorizer
az.routeTablesClient.Authorizer = authorizer
az.groupsClient.Authorizer = authorizer
az.deploymentsClient.Authorizer = authorizer
}
func (az *azClient) SetSender(sender autorest.Sender) {
az.appGatewaysClient.Client.Sender = sender
}
func (az *azClient) SetDuration(retryDuration time.Duration) {
az.appGatewaysClient.Client.RetryDuration = retryDuration
}
func (az *azClient) WaitForGetAccessOnGateway(maxRetryCount int) (err error) {
klog.V(3).Info("Getting Application Gateway configuration.")
err = utils.Retry(maxRetryCount, retryPause,
func() (utils.Retriable, error) {
response, err := az.appGatewaysClient.Get(az.ctx, string(az.resourceGroupName), string(az.appGwName))
if err == nil {
return utils.Retriable(true), nil
}
e := controllererrors.NewErrorWithInnerErrorf(
controllererrors.ErrorGetApplicationGatewayError,
err,
"Failed fetching configuration for Application Gateway. Will retry in %v.", retryPause,
)
if response.Response.Response != nil {
e = controllererrors.NewErrorWithInnerErrorf(
controllererrors.ErrorApplicationGatewayUnexpectedStatusCode,
err,
"Unexpected status code '%d' while performing a GET on Application Gateway.", response.Response.StatusCode,
)
if response.Response.StatusCode == 404 {
e.Code = controllererrors.ErrorApplicationGatewayNotFound
}
if response.Response.StatusCode == 403 {
e.Code = controllererrors.ErrorApplicationGatewayForbidden
clientID := "<agic-client-id>"
if az.clientID != "" {
clientID = az.clientID
}
groupID := ResourceGroupID(az.subscriptionID, az.resourceGroupName)
applicationGatewayID := ApplicationGatewayID(az.subscriptionID, az.resourceGroupName, az.appGwName)
roleAssignmentCmd := fmt.Sprintf("az role assignment create --role Reader --scope %s --assignee %s;"+
" az role assignment create --role Contributor --scope %s --assignee %s",
groupID,
clientID,
applicationGatewayID,
clientID,
)
e.Message += fmt.Sprintf(" You can use '%s' to assign permissions."+
" AGIC Identity needs at least 'Contributor' access to Application Gateway '%s' and 'Reader' access to Application Gateway's Resource Group '%s'.",
roleAssignmentCmd,
string(az.appGwName),
string(az.resourceGroupName),
)
}
if response.Response.StatusCode == 400 || response.Response.StatusCode == 401 {
klog.Errorf("configuration error (bad request) or unauthorized error while performing a GET using the authorizer")
klog.Errorf("stopping GET retries")
return utils.Retriable(false), e
}
}
klog.Errorf(e.Error())
if controllererrors.IsErrorCode(e, controllererrors.ErrorApplicationGatewayNotFound) {
return utils.Retriable(false), e
}
return utils.Retriable(true), e
})
return
}
func (az *azClient) GetGateway() (gateway n.ApplicationGateway, err error) {
err = utils.Retry(retryCount, retryPause,
func() (utils.Retriable, error) {
gateway, err = az.appGatewaysClient.Get(az.ctx, string(az.resourceGroupName), string(az.appGwName))
if err != nil {
klog.Errorf("Error while getting application gateway '%s': %s", string(az.appGwName), err)
}
return utils.Retriable(true), err
})
return
}
func (az *azClient) UpdateGateway(appGwObj *n.ApplicationGateway) (err error) {
appGwFuture, err := az.appGatewaysClient.CreateOrUpdate(az.ctx, string(az.resourceGroupName), string(az.appGwName), *appGwObj)
if err != nil {
return
}
if appGwFuture.PollingURL() != "" {
klog.V(3).Infof("OperationID='%s'", GetOperationIDFromPollingURL(appGwFuture.PollingURL()))
}
// Wait until deployment finshes and save the error message
err = appGwFuture.WaitForCompletionRef(az.ctx, az.appGatewaysClient.BaseClient.Client)
return
}
func (az *azClient) GetPublicIP(resourceID string) (n.PublicIPAddress, error) {
if ip, ok := az.memoizedIPs[resourceID]; ok {
return ip, nil
}
_, resourceGroupName, publicIPName := ParseResourceID(resourceID)
ip, err := az.publicIPsClient.Get(az.ctx, string(resourceGroupName), string(publicIPName), "")
if err != nil {
return n.PublicIPAddress{}, err
}
az.memoizedIPs[resourceID] = ip
return ip, nil
}
func (az *azClient) ApplyRouteTable(subnetID string, routeTableID string) error {
// Check if the route table exists
_, routeTableResourceGroup, routeTableName := ParseResourceID(routeTableID)
routeTable, err := az.routeTablesClient.Get(az.ctx, string(routeTableResourceGroup), string(routeTableName), "")
// if route table is not found, then simply add a log and return no error. routeTable will always be initialized.
if routeTable.Response.StatusCode == 404 {
klog.V(3).Infof("Error getting route table '%s' (this is relevant for AKS clusters using 'Kubenet' network plugin): %s",
routeTableID,
err.Error())
return nil
}
if err != nil {
// no access or no route table
return err
}
// Get subnet and check if it is already associated to a route table
_, subnetResourceGroup, subnetVnetName, subnetName := ParseSubResourceID(subnetID)
subnet, err := az.subnetsClient.Get(az.ctx, string(subnetResourceGroup), string(subnetVnetName), string(subnetName), "")
if err != nil {
return err
}
if subnet.RouteTable != nil {
if *subnet.RouteTable.ID != routeTableID {
klog.V(3).Infof("Skipping associating Application Gateway subnet '%s' with route table '%s' used by k8s cluster as it is already associated to route table '%s'.",
subnetID,
routeTableID,
*subnet.SubnetPropertiesFormat.RouteTable.ID)
} else {
klog.V(3).Infof("Application Gateway subnet '%s' is associated with route table '%s' used by k8s cluster.",
subnetID,
routeTableID)
}
return nil
}
klog.Infof("Associating Application Gateway subnet '%s' with route table '%s' used by k8s cluster.", subnetID, routeTableID)
subnet.RouteTable = &routeTable
subnetFuture, err := az.subnetsClient.CreateOrUpdate(az.ctx, string(subnetResourceGroup), string(subnetVnetName), string(subnetName), subnet)
if err != nil {
return err
}
// Wait until deployment finshes and save the error message
err = subnetFuture.WaitForCompletionRef(az.ctx, az.subnetsClient.BaseClient.Client)
if err != nil {
return err
}
return nil
}
func (az *azClient) GetSubnet(subnetID string) (n.Subnet, error) {
_, subnetResourceGroup, subnetVnetName, subnetName := ParseSubResourceID(subnetID)
subnet, err := az.subnetsClient.Get(az.ctx, string(subnetResourceGroup), string(subnetVnetName), string(subnetName), "")
return subnet, err
}
// DeployGatewayWithVnet creates Application Gateway within the specifid VNet. Implements AzClient interface.
func (az *azClient) DeployGatewayWithVnet(resourceGroupName ResourceGroup, vnetName ResourceName, subnetName ResourceName, subnetPrefix, skuName string) (err error) {
vnet, err := az.getVnet(resourceGroupName, vnetName)
if err != nil {
return
}
klog.Infof("Checking the Vnet %s for a subnet with prefix %s", vnetName, subnetPrefix)
subnet, err := az.findSubnet(vnet, subnetName, subnetPrefix)
if err != nil {
if subnetPrefix == "" {
klog.Infof("Unable to find a subnet with subnetName %s. Please provide subnetPrefix in order to allow AGIC to create a subnet in Vnet %s", subnetName, vnetName)
return
}
klog.Infof("Unable to find a subnet. Creating a subnet %s with prefix %s in Vnet %s", subnetName, subnetPrefix, vnetName)
subnet, err = az.createSubnet(vnet, subnetName, subnetPrefix)
if err != nil {
return
}
}
err = az.DeployGatewayWithSubnet(*subnet.ID, skuName)
return
}
// DeployGatewayWithSubnet creates Application Gateway within the specifid subnet. Implements AzClient interface.
func (az *azClient) DeployGatewayWithSubnet(subnetID, skuName string) (err error) {
klog.Infof("Deploying Gateway")
// Check if group exists
group, err := az.getGroup()
if err != nil {
return
}
klog.Infof("Using resource group: %v", *group.Name)
deploymentName := string(az.appGwName)
klog.Infof("Starting ARM template deployment: %s", deploymentName)
result, err := az.createDeployment(subnetID, skuName)
if err != nil {
return
}
if result.Name != nil {
klog.Infof("Completed deployment %v: %v", deploymentName, result.Properties.ProvisioningState)
} else {
klog.Infof("Completed deployment %v (no data returned to SDK)", deploymentName)
}
return
}
// Create a resource group for the deployment.
func (az *azClient) getGroup() (group r.Group, err error) {
utils.Retry(retryCount, retryPause,
func() (utils.Retriable, error) {
group, err = az.groupsClient.Get(az.ctx, string(az.resourceGroupName))
if err != nil {
klog.Errorf("Error while getting resource group '%s': %s", az.resourceGroupName, err)
}
return utils.Retriable(true), err
})
return
}
func (az *azClient) getVnet(resourceGroupName ResourceGroup, vnetName ResourceName) (vnet n.VirtualNetwork, err error) {
utils.Retry(extendedRetryCount, retryPause,
func() (utils.Retriable, error) {
vnet, err = az.virtualNetworksClient.Get(az.ctx, string(resourceGroupName), string(vnetName), "")
if err != nil {
klog.Errorf("Error while getting virtual network '%s': %s", vnetName, err)
}
return utils.Retriable(true), err
})
return
}
func (az *azClient) findSubnet(vnet n.VirtualNetwork, subnetName ResourceName, subnetPrefix string) (subnet n.Subnet, err error) {
for _, subnet := range *vnet.Subnets {
if string(subnetName) == *subnet.Name && (subnetPrefix == "" || subnetPrefix == *subnet.AddressPrefix) {
return subnet, nil
}
}
err = controllererrors.NewErrorf(
controllererrors.ErrorSubnetNotFound,
"Unable to find subnet with matching subnetName %s and subnetPrefix %s in virtual network %s", subnetName, subnetPrefix, *vnet.ID,
)
return
}
func (az *azClient) createSubnet(vnet n.VirtualNetwork, subnetName ResourceName, subnetPrefix string) (subnet n.Subnet, err error) {
_, resourceGroup, vnetName := ParseResourceID(*vnet.ID)
subnet = n.Subnet{
SubnetPropertiesFormat: &n.SubnetPropertiesFormat{
AddressPrefix: &subnetPrefix,
},
}
subnetFuture, err := az.subnetsClient.CreateOrUpdate(az.ctx, string(resourceGroup), string(vnetName), string(subnetName), subnet)
if err != nil {
return
}
// Wait until deployment finshes and save the error message
err = subnetFuture.WaitForCompletionRef(az.ctx, az.subnetsClient.BaseClient.Client)
if err != nil {
return
}
return az.subnetsClient.Get(az.ctx, string(resourceGroup), string(vnetName), string(subnetName), "")
}
// Create the deployment
func (az *azClient) createDeployment(subnetID, skuName string) (deployment r.DeploymentExtended, err error) {
template := getTemplate()
if err != nil {
return
}
params := map[string]interface{}{
"applicationGatewayName": map[string]string{
"value": string(az.appGwName),
},
"applicationGatewaySubnetId": map[string]string{
"value": subnetID,
},
"applicationGatewaySku": map[string]string{
"value": skuName,
},
}
deploymentFuture, err := az.deploymentsClient.CreateOrUpdate(
az.ctx,
string(az.resourceGroupName),
string(az.appGwName),
r.Deployment{
Properties: &r.DeploymentProperties{
Template: template,
Parameters: params,
Mode: r.DeploymentModeIncremental,
},
},
)
if err != nil {
return
}
err = deploymentFuture.WaitForCompletionRef(az.ctx, az.deploymentsClient.BaseClient.Client)
if err != nil {
return
}
return deploymentFuture.Result(az.deploymentsClient)
}
func getTemplate() map[string]interface{} {
template := `
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"applicationGatewayName": {
"defaultValue": "appgw",
"type": "string",
"metadata": {
"description": "Name of the Application Gateway."
}
},
"applicationGatewaySubnetId": {
"type": "string",
"metadata": {
"description": "Resource Id of Subnet in which Application Gateway will be deployed."
}
},
"applicationGatewaySku": {
"allowedValues": [
"Standard_v2",
"WAF_v2"
],
"type": "string",
"metadata": {
"description": "The sku of the Application Gateway. Default: WAF_v2 (Detection mode). In order to further customize WAF, use azure portal or cli."
}
}
},
"variables": {
"resgpguid": "[substring(replace(guid(resourceGroup().id), '-', ''), 0, 4)]",
"vnetName": "[concat('virtualnetwork' , variables('resgpguid'))]",
"applicationGatewayPublicIpName": "[concat(parameters('applicationGatewayName'), '-appgwpip')]",
"applicationGatewayPublicIpId": "[resourceId('Microsoft.Network/publicIPAddresses',variables('applicationGatewayPublicIpName'))]",
"applicationGatewayId": "[resourceId('Microsoft.Network/applicationGateways', parameters('applicationGatewayName'))]",
"webApplicationFirewallConfiguration": {
"enabled": "true",
"firewallMode": "Detection"
}
},
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('applicationGatewayPublicIpName')]",
"apiVersion": "2018-08-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAllocationMethod": "Static"
}
},
{
"type": "Microsoft.Network/applicationGateways",
"name": "[parameters('applicationGatewayName')]",
"apiVersion": "2018-08-01",
"location": "[resourceGroup().location]",
"tags": {
"managed-by-k8s-ingress": "true",
"created-by": "ingress-appgw"
},
"properties": {
"sku": {
"name": "[parameters('applicationGatewaySku')]",
"tier": "[parameters('applicationGatewaySku')]",
"capacity": 2
},
"gatewayIPConfigurations": [
{
"name": "appGatewayIpConfig",
"properties": {
"subnet": {
"id": "[parameters('applicationGatewaySubnetId')]"
}
}
}
],
"frontendIPConfigurations": [
{
"name": "appGatewayFrontendIP",
"properties": {
"PublicIPAddress": {
"id": "[variables('applicationGatewayPublicIpId')]"
}
}
}
],
"frontendPorts": [
{
"name": "httpPort",
"properties": {
"Port": 80
}
},
{
"name": "httpsPort",
"properties": {
"Port": 443
}
}
],
"backendAddressPools": [
{
"name": "bepool",
"properties": {
"backendAddresses": []
}
}
],
"httpListeners": [
{
"name": "httpListener",
"properties": {
"protocol": "Http",
"frontendPort": {
"id": "[concat(variables('applicationGatewayId'), '/frontendPorts/httpPort')]"
},
"frontendIPConfiguration": {
"id": "[concat(variables('applicationGatewayId'), '/frontendIPConfigurations/appGatewayFrontendIP')]"
}
}
}
],
"backendHttpSettingsCollection": [
{
"name": "setting",
"properties": {
"port": 80,
"protocol": "Http"
}
}
],
"requestRoutingRules": [
{
"name": "rule1",
"properties": {
"httpListener": {
"id": "[concat(variables('applicationGatewayId'), '/httpListeners/httpListener')]"
},
"backendAddressPool": {
"id": "[concat(variables('applicationGatewayId'), '/backendAddressPools/bepool')]"
},
"backendHttpSettings": {
"id": "[concat(variables('applicationGatewayId'), '/backendHttpSettingsCollection/setting')]"
}
}
}
],
"webApplicationFirewallConfiguration": "[if(equals(parameters('applicationGatewaySku'), 'WAF_v2'), variables('webApplicationFirewallConfiguration'), json('null'))]"
},
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('applicationGatewayPublicIpName'))]"
]
}
],
"outputs": {
"subscriptionId": {
"type": "string",
"value": "[subscription().subscriptionId]"
},
"resourceGroupName": {
"type": "string",
"value": "[resourceGroup().name]"
},
"applicationGatewayName": {
"type": "string",
"value": "[parameters('applicationGatewayName')]"
}
}
}`
contents := make(map[string]interface{})
json.Unmarshal([]byte(template), &contents)
return contents
}