Azure App Service Custom Hostnames - azure

We're hosting our application on Azure and need to add a sub domain in the custom hostname section. We need to do this dynamically so needs to be done at run time.
I've tried using the Azure management rest API but can't seem to find the app when making any call.
Whats the best way to add a custom header to an app service with out using the Azure portal?
Thanks in advance.

You could place an API Management in front of you app and use the "Set HTTP header" transformation policy to add a custom header to the request:
Assigns a value to an existing response and/or request header or adds
a new response and/or request header

Going through the API docs they had a call that did what we needed.
https://learn.microsoft.com/en-us/rest/api/appservice/webapps/createorupdatehostnamebinding

Related

Can you use App Configuration service with API Management instead of NVPs?

I am trying to make my ARM templates that I'm generating by the APIM Resource Kit as generic as possible to promote API changes, etc. through Dev/QA/Prod environments.
The way I've found to set back end endpoints per environment is by name/value pairs via policies. It occurred to me doing this through the App Configuration instead of NVPs would allow me to make this more generic in the ARM templates. Does anyone know if there's a way to do this or can point in me in the right direction?
I figured out in the APIM resource kit, the serviceUrlParameters paramater for the extractor tool will handle generating out the files needed to make the backend endpoints configurable.

How to programmatically update Networking Access Restriction on Azure Web App

I have an Azure webapp and normally if I want to block an IP address, I go to Azure dashboard panel and under networking>Configure Access Restrictions, I add a rule to do so. This picture shows which menu item I mean:
However, I would like to do this programmatically. I see that the documentation shows how you can do this through Powershell.
I have also managed to find the API documentation for WebApp. But I can't find the last piece of the puzzle which is the API that does what I need.
Can someone please tell me if it is possible and which API I should use? Thank you in advance.
According to the doc: Use an Azure REST API PUT operation on the app configuration in Azure Resource Manager. The location for this information in Azure Resource Manager is:
management.azure.com/subscriptions/subscription ID/resourceGroups/resource groups/providers/Microsoft.Web/sites/web app name/config/web?api-version=2020-06-01
Then I searched the Azure Rest API and found this:
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/web?api-version=2019-08-01
We could update the field properties.ipSecurityRestrictions to update the value of Access Restrictions.
In addition, you could also check this blog: Bulk add IP Access Restrictions to Azure App Service using Az PowerShell
There does not appear to be a one-to-one match between powershell commands and api.
The closest I could find is:
https://learn.microsoft.com/en-us/rest/api/appservice/webapps/putprivateaccessvnet
This allows you to define which vnet has access to your web app. By controlling access to your vnet, you can control access to your app.

How to automate the update of Web Service URL in Azure API management

How to automate the update of Web Service URL in Azure API management when CI/CD pipeline executes resulting in change of external IP.
You need to use the Open API specs from your APIs and use REST API / Powershell to update or add routes in API Management. There's also an extension but I am not sure if it's updated or not. You can read more about in here:
https://github.com/Azure/azure-api-management-devops-resource-kit

Configuring Access-Control-Allow-Headers in Azure Functions

I have an API built through Azure Functions that works when called through JavaScript in all browsers except for Safari. From another question, it appears I need to allow a header of "Origin" in the CORS configuration. The only configuration I see in the Azure portal is allowing origins. How do I configure allowed headers?
If it matters, this is developed and published through VS2017 Azure function tools.
How do I configure allowed headers?
It seems that we also could do that with Azure portal. More details info please refer to the screenshot.
To allow all, use "*" and remove all other origins from the list. Slashes are not allowed as part of domain or after TLD.
Allowed headers are not configurable within Azure Functions as it allows all.

Azure Traffic Manager support with Azure Function Apps

I am trying to use Azure Traffic Manager (GTM) to geographically distribute load to function apps in each region.
I have tried adding an 'app service endpoint' and an 'external endpoint' (including adding the GTM name as a custom CNAME to the function app), but both result in "Error 404 - Web app not found.". The custom CNAME also never adds correctly.
According to the last comment on this post, the ability to do this should now be supported:
Setting up a custom domain with an Azure Function app
I am unable to comment back on the post as I am a new user.
I have tried adding an 'app service endpoint' and an 'external endpoint' (including adding the GTM name as a custom CNAME to the function app)
Azure Traffic Manager is only eligible for use with App Services at the 'Standard' level or above as mentioned here. If your function isn't host in an app plan at the 'Standard' level or above, Azure Traffic Manager will not work.
If you are not using 'Standard' or higher level app plan, Azure Functions Proxies would be a workaround for you. Please check following thread which discuss the similar problem.
Azure Functions Traffic Manager
Here is the quick reference from the answer provided by Dakota Kincer.
So the answer I arrived to after Traffic manager didntsupport Azure functions was to overall build 3 Azure functions. I built an East and a West that has my azure function code on it. Then I built a main Azure Function that has 0 code. It only has Azure proxies on it that route to my 2 other Azure Functions. The route is controlled by a variable in the proxy string that is help in the main API app settings. Using %myvariable% you can set part of the url. When I need to publish I switch the variable to the secondary URL location. Update the Primary and then switch the URL to its original primary location. This will have to work for now till traffic manager is integrated into functions or a better solution arises.
I am unable to comment back on the post as I am a new user.
You could modify your post if you want to provide more information.
Traffic Manager supports Azure functions monitoring. You can enable this by going to TM settings -> endpoints -> add endpoint -> choose Azure endpoint type -> App Service for Target resource type -> under Target Resource choose Function app which you want to monitor.
Most likely you want to be able to access function apps under specific domain domain, for example my-domain.com. For that under Custom Header Settings specify host:my-domain.com. You'll need to setup custom domain in function apps configuration too.

Resources