Problem: Domains are handled by Azure DNS. One (or multiple) subdomains are pointing to a dynamic (public) IP and need to be updated on IP change.
Solution: An Azure Function that can be triggered by any authorized ddclient, basically DynDNS on Azure. ddclient is not required, as long as the dynDNS API-specs are followed.
Use-Case: Ubiquiti USG / Ubiquiti UDM dynamic DNS feature.
- Set up you DNS Zones in Azure
- Set up your Azure Function App (v4/.NET6, consumption plan, Application Insights enabled)
- Deploy this Azure Function to your Function App resource and configure Application Settings accordingly
Managed identity is turned on for the azure function provided in this code. This means that the azure function will function as it's own identity with it's own accesses to azure resources.
To check that you have Managed Identity turned on visit the azure function and look for Identity in the blade to the left on the azure portal.
Now we just need to assign the managed access to the azure DNS zone we want to configure.
detailed walk-through: (https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal?tabs=current)
- Select "Access control (IAM)" in your DNS resource (or resource group if you have multiple DNS Zones that you want to modify)
- Click on "Add role assignment"
- Search for "DNS Zone Contributor", select it and click "Next"
- Click "Select Members" and search for your Managed Identtity. The name of the managed identity is identical to the name of the azure function
- Click "Next" and then "Review + assign"
You can double check the success of your operation by providing your Azure Function name to the "Check access" form
- tenantId - you can get this from your AAD Overview page
- subscriptionId - the GUID of your subscription, can be found in the overview page of any resource
- rgName - the name of the resource group that holds your DNS Zone resources
Set up local.settings.yaml with the following keys
{
"Values": {
"clientPassword": "password"
"clientUsername": "username",
"fqdn": "<fqdn>",
"resourceGroupName": "<rg>",
}
}
Add the following keys to your AppSettings.
Name | Value |
---|---|
clientPassword | password for dyndns client |
clientUsername | username for dyndns client |
fqdn | Your domain name. must contain a subdomain |
resourceGroupName | Name of the resource group with the dynamic DNS |