Reputation: 3068
I am trying to automate adding custom domain to Azure App.
Here's what I thought of doing:
customDomain
query param.Here's what I setup in function App:
run.ps1
param($req, $TriggerMetadata)
$customDomain = $req.Query.customDomain
Set-AzWebApp `
-Name some-app `
-ResourceGroupName SouthEastAsia `
-HostNames @($customDomain,"some-app.azurewebsites.net")
Push-OutputBinding -Name res -Value ([HttpResponseContext]@{
StatusCode = [System.Net.HttpStatusCode]::OK
Body = "Added Custom Domain: $customDomain"
})
function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "./run.ps1"
}
But this is giving me 404 NotFound error when I trigger a HTTP Get request:
https://function.domain/api/AddCustomDomain?customDomain=test
Upvotes: 0
Views: 673
Reputation: 1424
Is there a specific reason to pass an array into the -Hostnames
param? It looks like you're trying to specify the default Azure hostname but it won't be required.
Try Set-AzWebApp -Name some-app -ResourceGroupName SouthEastAsia -HostNames "$customDomain"
If you do need multiple custom domains try wrapping your var
in quotes Set-AzWebApp -Name some-app -ResourceGroupName SouthEastAsia -HostNames @("$customDomain1","$customDomain2","$customDomain3")
Upvotes: 0