Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created November 17, 2017 00:36
Show Gist options
  • Save justinyoo/20b333e928dedccc1d4046680b0b9ca4 to your computer and use it in GitHub Desktop.
Save justinyoo/20b333e928dedccc1d4046680b0b9ca4 to your computer and use it in GitHub Desktop.
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