您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

用于 .NET 的 Azure DNS 库Azure DNS libraries for .NET

使用用于 .NET 的 Microsoft Azure DNS 库可创建和修改 Azure 中托管的 DNS 区域与记录。Use the Microsoft Azure DNS libraries for .NET to create and modify DNS zones and records hosted within Azure. 区域和记录以 Azure 资源的形式进行管理。Zones and records are managed as Azure Resources. 请阅读 Azure DNS 概述了解详细信息。Learn more by reading the Azure DNS overview.

管理库Management library

使用管理库可创建和修改 Azure 中托管的 DNS 区域与记录。Use the management library to create and modify DNS zones and records that are hosted in Azure.

直接从 Visual Studio 包管理器控制台或使用 .NET Core CLI 安装 NuGet 包Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio 包管理器Visual Studio Package Manager

Install-Package Microsoft.Azure.Management.Dns
dotnet add package Microsoft.Azure.Management.Dns

示例Example

以下示例创建新的 DNS 区域。The following example creates a new DNS zone.

/*
using Microsoft.Rest.Azure.Authentication;
using Microsoft.Azure.Management.Dns;
using Microsoft.Azure.Management.Dns.Models;
*/
Microsoft.Rest.ServiceClientCredentials serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, secret);
DnsManagementClient dnsClient = new DnsManagementClient(serviceCreds);            
Zone dnsZoneParams = new Zone("global");
dnsZoneParams.Tags = new Dictionary<string, string>();
dnsZoneParams.Tags.Add("dept", "finance");
Zone dnsZone =
    await dnsClient.Zones.CreateOrUpdateAsync(resourceGroupName, zoneName, dnsZoneParams, null, "*");

示例Samples

详细了解可在应用中使用的示例 .NET 代码Explore more sample .NET code you can use in your apps.