Exemple #1
0
        public async Task UpdateFirewallSettings(UpdateRequestMessage requestMessage)
        {
            var ipAddressesToRemove = GetIpAddressesToRemove(requestMessage.OutboundIpAddresses);
            var newFirewallRules    = BuildNewFirewallRules(requestMessage.OutboundIpAddresses, ipAddressesToRemove, requestMessage.FirewallSettings.firewallRules);

            var result =
                await analysisService.SetFirewallRulesAsync(requestMessage.AccessToken,
                                                            requestMessage.UpdateFirewallRulesRequestMessage.analysisServerSubscriptionId,
                                                            requestMessage.UpdateFirewallRulesRequestMessage.analysisServerResourceGroup,
                                                            requestMessage.UpdateFirewallRulesRequestMessage.analysisServerName,
                                                            new IpV4FirewallSettings
            {
                enablePowerBIService = requestMessage.FirewallSettings.enablePowerBIService,
                firewallRules        = newFirewallRules
            });

            if (result.IsSuccessStatusCode)
            {
                log.LogTrace($"Successfully updated firewall rules using {requestMessage.OutboundIpAddresses}");
                OutboundIpAddresses = requestMessage.OutboundIpAddresses;
            }
            else
            {
                var message = $"Failed to update firewall rules using {requestMessage.OutboundIpAddresses}; reason: {result.ReasonPhrase}";
                log.LogTrace(message);
                throw new Exception(message);
            }
        }
Exemple #2
0
        public async Task <IActionResult> SetFirewallSettings(
            [HttpTrigger(AuthorizationLevel.Function, "patch", "post", Route = "subscriptions/{subscriptionId}/groups/{group}/analysisservers/{server}/firewallsettings")] HttpRequestMessage req, string subscriptionId, string group, string server)
        {
            IpV4FirewallSettings firewallSettings = await req.Content.ReadAsAsync <IpV4FirewallSettings>();

            if (firewallSettings == null)
            {
                return(new BadRequestObjectResult(new ArgumentNullException("message body invalid or not found")));
            }

            var accessToken = await aadService.GetAccessTokenAsync();

            var result = await analysisService.SetFirewallRulesAsync(accessToken, subscriptionId, group, server, firewallSettings);

            if (result.IsSuccessStatusCode)
            {
                return(new OkResult());
            }
            else
            {
                return(new BadRequestObjectResult(result.ReasonPhrase));
            }
        }