We recommend using Azure Native.
published on Monday, Feb 23, 2026 by Pulumi
We recommend using Azure Native.
published on Monday, Feb 23, 2026 by Pulumi
Use this data source to access information about an existing DNS MX Record within Azure DNS.
Note: The Azure DNS API has a throttle limit of 500 read (GET) operations per 5 minutes - whilst the default read timeouts will work for most cases - in larger configurations you may need to set a larger read timeout then the default 5min. Although, we’d generally recommend that you split the resources out into smaller Terraform configurations to avoid the problem entirely.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.dns.getMxRecord({
name: "test",
zoneName: "test-zone",
resourceGroupName: "test-rg",
});
export const dnsMxRecordId = example.then(example => example.id);
import pulumi
import pulumi_azure as azure
example = azure.dns.get_mx_record(name="test",
zone_name="test-zone",
resource_group_name="test-rg")
pulumi.export("dnsMxRecordId", example.id)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/dns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := dns.LookupMxRecord(ctx, &dns.LookupMxRecordArgs{
Name: pulumi.StringRef("test"),
ZoneName: "test-zone",
ResourceGroupName: "test-rg",
}, nil)
if err != nil {
return err
}
ctx.Export("dnsMxRecordId", example.Id)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Dns.GetMxRecord.Invoke(new()
{
Name = "test",
ZoneName = "test-zone",
ResourceGroupName = "test-rg",
});
return new Dictionary<string, object?>
{
["dnsMxRecordId"] = example.Apply(getMxRecordResult => getMxRecordResult.Id),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.dns.DnsFunctions;
import com.pulumi.azure.dns.inputs.GetMxRecordArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = DnsFunctions.getMxRecord(GetMxRecordArgs.builder()
.name("test")
.zoneName("test-zone")
.resourceGroupName("test-rg")
.build());
ctx.export("dnsMxRecordId", example.id());
}
}
variables:
example:
fn::invoke:
function: azure:dns:getMxRecord
arguments:
name: test
zoneName: test-zone
resourceGroupName: test-rg
outputs:
dnsMxRecordId: ${example.id}
API Providers
This data source uses the following Azure API Providers:
Microsoft.Network- 2018-05-01
Using getMxRecord
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getMxRecord(args: GetMxRecordArgs, opts?: InvokeOptions): Promise<GetMxRecordResult>
function getMxRecordOutput(args: GetMxRecordOutputArgs, opts?: InvokeOptions): Output<GetMxRecordResult>def get_mx_record(name: Optional[str] = None,
resource_group_name: Optional[str] = None,
zone_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetMxRecordResult
def get_mx_record_output(name: Optional[pulumi.Input[str]] = None,
resource_group_name: Optional[pulumi.Input[str]] = None,
zone_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetMxRecordResult]func LookupMxRecord(ctx *Context, args *LookupMxRecordArgs, opts ...InvokeOption) (*LookupMxRecordResult, error)
func LookupMxRecordOutput(ctx *Context, args *LookupMxRecordOutputArgs, opts ...InvokeOption) LookupMxRecordResultOutput> Note: This function is named LookupMxRecord in the Go SDK.
public static class GetMxRecord
{
public static Task<GetMxRecordResult> InvokeAsync(GetMxRecordArgs args, InvokeOptions? opts = null)
public static Output<GetMxRecordResult> Invoke(GetMxRecordInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetMxRecordResult> getMxRecord(GetMxRecordArgs args, InvokeOptions options)
public static Output<GetMxRecordResult> getMxRecord(GetMxRecordArgs args, InvokeOptions options)
fn::invoke:
function: azure:dns/getMxRecord:getMxRecord
arguments:
# arguments dictionaryThe following arguments are supported:
- Resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists.
- Zone
Name string - Specifies the DNS Zone where the resource exists.
- Name string
- The name of the DNS MX Record.
- Resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists.
- Zone
Name string - Specifies the DNS Zone where the resource exists.
- Name string
- The name of the DNS MX Record.
- resource
Group StringName - Specifies the resource group where the DNS Zone (parent resource) exists.
- zone
Name String - Specifies the DNS Zone where the resource exists.
- name String
- The name of the DNS MX Record.
- resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists.
- zone
Name string - Specifies the DNS Zone where the resource exists.
- name string
- The name of the DNS MX Record.
- resource_
group_ strname - Specifies the resource group where the DNS Zone (parent resource) exists.
- zone_
name str - Specifies the DNS Zone where the resource exists.
- name str
- The name of the DNS MX Record.
- resource
Group StringName - Specifies the resource group where the DNS Zone (parent resource) exists.
- zone
Name String - Specifies the DNS Zone where the resource exists.
- name String
- The name of the DNS MX Record.
getMxRecord Result
The following output properties are available:
- Fqdn string
- The FQDN of the DNS MX Record.
- Id string
- The provider-assigned unique ID for this managed resource.
- Records
List<Get
Mx Record Record> - A list of values that make up the MX record. Each
recordblock supports fields documented below. - Resource
Group stringName - Dictionary<string, string>
- A mapping of tags assigned to the resource.
- Ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- Zone
Name string - Name string
- Fqdn string
- The FQDN of the DNS MX Record.
- Id string
- The provider-assigned unique ID for this managed resource.
- Records
[]Get
Mx Record Record - A list of values that make up the MX record. Each
recordblock supports fields documented below. - Resource
Group stringName - map[string]string
- A mapping of tags assigned to the resource.
- Ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- Zone
Name string - Name string
- fqdn String
- The FQDN of the DNS MX Record.
- id String
- The provider-assigned unique ID for this managed resource.
- records
List<Get
Mx Record Record> - A list of values that make up the MX record. Each
recordblock supports fields documented below. - resource
Group StringName - Map<String,String>
- A mapping of tags assigned to the resource.
- ttl Integer
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name String - name String
- fqdn string
- The FQDN of the DNS MX Record.
- id string
- The provider-assigned unique ID for this managed resource.
- records
Get
Mx Record Record[] - A list of values that make up the MX record. Each
recordblock supports fields documented below. - resource
Group stringName - {[key: string]: string}
- A mapping of tags assigned to the resource.
- ttl number
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name string - name string
- fqdn str
- The FQDN of the DNS MX Record.
- id str
- The provider-assigned unique ID for this managed resource.
- records
Sequence[Get
Mx Record Record] - A list of values that make up the MX record. Each
recordblock supports fields documented below. - resource_
group_ strname - Mapping[str, str]
- A mapping of tags assigned to the resource.
- ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- zone_
name str - name str
- fqdn String
- The FQDN of the DNS MX Record.
- id String
- The provider-assigned unique ID for this managed resource.
- records List<Property Map>
- A list of values that make up the MX record. Each
recordblock supports fields documented below. - resource
Group StringName - Map<String>
- A mapping of tags assigned to the resource.
- ttl Number
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name String - name String
Supporting Types
GetMxRecordRecord
- Exchange string
- The mail server responsible for the domain covered by the MX record.
- Preference string
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- Exchange string
- The mail server responsible for the domain covered by the MX record.
- Preference string
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange String
- The mail server responsible for the domain covered by the MX record.
- preference String
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange string
- The mail server responsible for the domain covered by the MX record.
- preference string
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange str
- The mail server responsible for the domain covered by the MX record.
- preference str
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange String
- The mail server responsible for the domain covered by the MX record.
- preference String
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
published on Monday, Feb 23, 2026 by Pulumi
