Code-less redirection with serverless Azure Functions
How to quickly and simply configure redirections without writing code in Azure Functions
Say you want to have a nicer URI for something (like an Azure storage blob, a feed or something else). You likely have a nice short custom domain (i.e. I use kzu.io for things like this), and would like to set up arbitrary (temporary or permanent) redirections. This can trivially be achieved by creating an empty Functions App and leveraging Functions Proxies.
The proxies.json file for code-less redirects looks as follows:
1
{
2
"$schema": "http://json.schemastore.org/proxies",
3
"proxies": {
4
"[SOME_ID]": {
5
"matchCondition": {
6
"methods": [ "GET" ],
7
"route": "[SHORT_PATH_HERE]"
8
},
9
"responseOverrides": {
10
"response.statusCode": "[301|302|307|308|",
11
"response.headers.location": "[LONG_URL_HERE]"
12
}
13
}
14
}
15
}
Copied!
You can have as many of those IDs/entries as needed. For example, this is one I use to set up https://pkg.kzu.io/index.json > https://kzu.blob.core.windows.net/nuget/index.json:
1
{
2
"$schema": "http://json.schemastore.org/proxies",
3
"proxies": {
4
"default": {
5
"matchCondition": {
6
"methods": [ "GET" ],
7
"route": "index.json"
8
},
9
"responseOverrides": {
10
"response.statusCode": "307",
11
"response.headers.location": "https://kzu.blob.core.windows.net/nuget/index.json"
12
}
13
}
14
}
15
}
Copied!
Last modified 1mo ago
Copy link