Is it the traditional way via C# code e.g. config.EnableCors(); or can it also be done via Azure Portal magic?
Thanks @Lex Li for the comment.
We can configure CORS either from code
or from Azure Portal
=> Deployed App Service
.
To enable CORS
in Azure App Service
,
Navigate to the deployed App Service
in Azure Portal
=> select CORS
UNDER API
.
As mentioned in the MSDoc we can also enable CORS
using Azure CLI.
My Initial CORS
section:

Run the below command in Azure Cloud Shell
.
az webapp cors add --resource-group YourResourceGroup --name YourAppServiceName --allowed-origins 'URL of the Application or * '

Now, check the CORS
section under API
.
You can see the Allowed Origins
is added.

- If you set
CORS
policy in both Code
and in Azure Portal
, then the setting of code will be overridden with the settings in Portal.
If the client App (App-#2) is hosted on (another) Azure App Service, where to find the external IP address which will be sent in Ajax calls to App-#1?
- In this case we can use the
hostname
directly instead of IP Address
like below
https://AppServiceName.azurewebsites.net/api/<controller>/<action
As mentioned in the GitHub use the below command to find the possibleOutboundIpAddresses
.
