I want to get my client's IP Address (for example, Chrome browser) and then use it to generate SAS token for my blob storage resources.
For this im using this lines of code:
// In Startup.cs class:
services.AddHttpContextAccessor();
// In controller method:
// _httpContextAccessor is IHttpContextAccessor interface
var clientIpAddress = _httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress;
var blobClient = blobContainerClient.GetBlobClient();
var blobSasBuilder = new BlobSasBuilder
{
StartsOn = now,
ExpiresOn = now.AddMinutes(10),
BlobContainerName = blobClient.BlobContainerName,
IPRange = new SasIPRange(clientIpAddress) // im using clientIpAddress here
};
When i check my ip in https://www.myip.com/
site i get the ip that works with Azure portal gui for generating sas tokens (after generating it i can access resources on blob)
When i deploy my app to Azure the IP is completly diffrent than my ip from https://www.myip.com/
site and im not allowd to generate sas token for my chrome browser.
My question is, why when i deployed my App to Azure HttpContext
returns wrong client Ip adress?