Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Outbound IP Registration to Azure SQL Using Azure Functions
[FunctionName("UpdateFirewallRulesHttpTrigger")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "firewall/rules")]HttpRequestMessage req,
TraceWriter log)
{
...
log.Info($"Firewall rules on database servers in {resourceGroupName} are updating...");
var res = await azure.WebApps
.Inner
.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName)
.ConfigureAwait(false);
var webapps = res.Body.ToList();
var outboundIps = webapps.SelectMany(p => p.OutboundIpAddresses.Split(','))
.Distinct()
.ToList();
log.Info($"Firewall rules on database servers in {resourceGroupName} have been updated.");
return req.CreateResponse(HttpStatusCode.OK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment