0

I'm currently working on a .NET project and I need to update an Azure Application Gateway using the Azure.ResourceManager library. I've previously attempted to use the UpdateAsync() methode available on the ApplicationGatewayResource object but it allow only to update tags, not the full gateway config.

ApplicationGatewayResource appGateway = await _armClient.GetApplicationGatewayResource(ResourceIdentifier.Parse(_configuration["Azure:ApplicationGatewayId"])).GetAsync();
                        
appGateway.Data.SslCertificates.Add(new ApplicationGatewaySslCertificate
{
    Name = name,
    Data = new BinaryData(pfx),
    Password = pfxPassword
});
await appGateway.UpdateAsync(new());

Can someone provide an updated example of how to update an Azure Application Gateway using the current version of Azure.ResourceManager library in .NET ? Any guidance would be greatly appreciated.

Thanks in advance.

frank_lbt
  • 426
  • 1
  • 7
  • 21

1 Answers1

0

After some research I finally found a solution:

ApplicationGatewayResource appGateway = await _armClient.GetApplicationGatewayResource(ResourceIdentifier.Parse(_configuration["Azure:ApplicationGatewayId"])).GetAsync();
                    
// Update gateway object 

var resourceGroup = _armClient.GetResourceGroupResource(Parse(_configuration["Azure:ResourceGroupId"]!));
var gatewayCollection = resourceGroup.GetApplicationGateways();
await gatewayCollection.CreateOrUpdateAsync(WaitUntil.Completed, appGateway.Data.Name, appGateway.Data);
frank_lbt
  • 426
  • 1
  • 7
  • 21