你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Azure.Provisioning.Dns simplifies declarative resource provisioning in .NET.
Getting started
Install the package
Install the client library for .NET with NuGet:
dotnet add package Azure.Provisioning.Dns --prerelease
Prerequisites
You must have an Azure subscription.
Authenticate the Client
Key concepts
This library allows you to specify your infrastructure in a declarative style using dotnet. You can then use azd to deploy your infrastructure to Azure directly without needing to write or maintain bicep or arm templates.
Examples
Create a DNS Zone
This template shows how to create a DNS zone within Azure DNS and how to add some record sets to it.
Infrastructure infra = new();
ProvisioningParameter zoneName = new(nameof(zoneName), typeof(string))
{
Description = "The name of the DNS zone to be created. Must have at least 2 segments, e.g. hostname.org",
Value = BicepFunction.Interpolate($"{BicepFunction.GetUniqueString(BicepFunction.GetResourceGroup().Id)}.azurequickstart.org")
};
infra.Add(zoneName);
ProvisioningParameter recordName = new(nameof(recordName), typeof(string))
{
Description = "The name of the DNS record to be created. The name is relative to the zone, not the FQDN.",
Value = "www"
};
infra.Add(recordName);
DnsZone zone = new(nameof(zone), DnsZone.ResourceVersions.V2018_05_01)
{
Name = zoneName,
Location = new AzureLocation("global")
};
infra.Add(zone);
DnsARecord aRecord = new(nameof(aRecord), DnsARecord.ResourceVersions.V2018_05_01)
{
Parent = zone,
Name = recordName,
TtlInSeconds = 3600,
ARecords =
{
new DnsARecordInfo() { Ipv4Address = IPAddress.Parse("203.0.113.1") },
new DnsARecordInfo() { Ipv4Address = IPAddress.Parse("203.0.113.2") }
}
};
infra.Add(aRecord);
Troubleshooting
- File an issue via GitHub Issues.
- Check previous questions or ask new ones on Stack Overflow using Azure and .NET tags.
Next steps
Contributing
For details on contributing to this repository, see the contributing guide.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (for example, label, comment). Follow the instructions provided by the bot. You'll only need to do this action once across all repositories using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any other questions or comments.