Created
November 17, 2017 00:36
-
-
Save justinyoo/20b333e928dedccc1d4046680b0b9ca4 to your computer and use it in GitHub Desktop.
Outbound IP Registration to Azure SQL Using Azure Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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