Esempio n. 1
0
        private async Task <string> GetPossibleOutboundIpAddresses(UpdateFirewallRulesRequestMessage input)
        {
            var accessToken = await aadService.GetAccessTokenAsync();

            log.LogTrace($"accessToken: {accessToken}");

            var credentials   = aadService.GetCredentials();
            var ipAddressList = await webAppService.GetPossibleOutboundIpAddressesAsync(credentials, input.webAppSubscriptionId, input.webAppResourceGroup, input.webAppName);

            log.LogTrace($"possible outbound Ip Addresses: {ipAddressList}");
            return(ipAddressList);
        }
        public async Task <IActionResult> GetPossibleOutboundIpAddresses(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "subscriptions/{subscriptionId}/groups/{group}/webApps/{app}/possibleOutboundIpAddresses")] HttpRequestMessage req,
            string subscriptionId, string group, string app)
        {
            log.LogTrace($"subscriptionId: {subscriptionId}, resource group: {group}, app: {app}");

            //var managedIdentityId = config.GetValue<string>("ManagedIdentityId");
            //var connectionString = "RunAs=App;AppId=" + managedIdentityId;
            //var tokenProvider = new AzureServiceTokenProvider(connectionString);
            //var accessToken = await tokenProvider.GetAccessTokenAsync(config.GetValue<string>("Resource"));
            //log.LogInformation($"accesstoken from mi: {accessToken}");

            var credentials   = adService.GetCredentials();
            var ipAddressList = await webAppService.GetPossibleOutboundIpAddressesAsync(credentials, subscriptionId, group, app);

            log.LogTrace($"possible outbound Ip Addresses: {ipAddressList}");

            return(new OkObjectResult(ipAddressList));
        }