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
public static class UpdateFirewallRulesHttpTrigger | |
{ | |
[FunctionName("UpdateFirewallRulesHttpTrigger")] | |
public static async Task<HttpResponseMessage> Run( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "firewall/rules")]HttpRequestMessage req, | |
TraceWriter log) | |
{ | |
var tenantId = Config.TenantId; | |
var subscriptionId = Config.SubscriptionId; | |
var clientId = Config.ClientId; | |
var clientSecret = Config.ClientSecret; | |
var credentials = | |
SdkContext.AzureCredentialsFactory | |
.FromServicePrincipal(clientId, | |
clientSecret, | |
tenantId, | |
AzureEnvironment.AzureGlobalCloud); | |
var logLevel = HttpLoggingDelegatingHandler.Level.Basic; | |
var azure = Azure.Configure() | |
.WithLogLevel(logLevel) | |
.Authenticate(credentials) | |
.WithSubscription(subscriptionId); | |
var resourceGroupName = Config.ResourceGroupName; | |
log.Info($"Firewall rules on database servers in {resourceGroupName} are updating..."); | |
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