Skip to content

Commit 13703fb

Browse files
Introduce Azure.Provisioning.Dns (#53497)
Co-authored-by: Copilot <[email protected]>
1 parent 58195f4 commit 13703fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4004
-4
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<PackageReference Update="Azure.ResourceManager.ContainerRegistry" Version="1.3.0" />
149149
<PackageReference Update="Azure.ResourceManager.ContainerService" Version="1.2.3" />
150150
<PackageReference Update="Azure.ResourceManager.CosmosDB" Version="1.4.0-beta.12" />
151+
<PackageReference Update="Azure.ResourceManager.Dns" Version="1.2.0-beta.2" />
151152
<PackageReference Update="Azure.ResourceManager.EventGrid" Version="1.1.0" />
152153
<PackageReference Update="Azure.ResourceManager.EventHubs" Version="1.2.0" />
153154
<PackageReference Update="Azure.ResourceManager.FrontDoor" Version="1.4.1" />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Release History
2+
3+
## 1.0.0-beta.1 (2025-11-07)
4+
5+
### Features Added
6+
7+
- Initial beta release of new Azure.Provisioning.Dns.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Azure Provisioning Dns client library for .NET
2+
3+
Azure.Provisioning.Dns simplifies declarative resource provisioning in .NET.
4+
5+
## Getting started
6+
7+
### Install the package
8+
9+
Install the client library for .NET with [NuGet](https://www.nuget.org/ ):
10+
11+
```dotnetcli
12+
dotnet add package Azure.Provisioning.Dns --prerelease
13+
```
14+
15+
### Prerequisites
16+
17+
> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/).
18+
19+
### Authenticate the Client
20+
21+
## Key concepts
22+
23+
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.
24+
25+
## Examples
26+
27+
### Create a DNS Zone
28+
29+
This template shows how to create a DNS zone within Azure DNS and how to add some record sets to it.
30+
31+
```C# Snippet:CreateAzureDnsNewZone
32+
Infrastructure infra = new();
33+
34+
ProvisioningParameter zoneName = new(nameof(zoneName), typeof(string))
35+
{
36+
Description = "The name of the DNS zone to be created. Must have at least 2 segments, e.g. hostname.org",
37+
Value = BicepFunction.Interpolate($"{BicepFunction.GetUniqueString(BicepFunction.GetResourceGroup().Id)}.azurequickstart.org")
38+
};
39+
infra.Add(zoneName);
40+
41+
ProvisioningParameter recordName = new(nameof(recordName), typeof(string))
42+
{
43+
Description = "The name of the DNS record to be created. The name is relative to the zone, not the FQDN.",
44+
Value = "www"
45+
};
46+
infra.Add(recordName);
47+
48+
DnsZone zone = new(nameof(zone), DnsZone.ResourceVersions.V2018_05_01)
49+
{
50+
Name = zoneName,
51+
Location = new AzureLocation("global")
52+
};
53+
infra.Add(zone);
54+
55+
DnsARecord aRecord = new(nameof(aRecord), DnsARecord.ResourceVersions.V2018_05_01)
56+
{
57+
Parent = zone,
58+
Name = recordName,
59+
TtlInSeconds = 3600,
60+
ARecords =
61+
{
62+
new DnsARecordInfo() { Ipv4Addresses = IPAddress.Parse("203.0.113.1") },
63+
new DnsARecordInfo() { Ipv4Addresses = IPAddress.Parse("203.0.113.2") }
64+
}
65+
};
66+
infra.Add(aRecord);
67+
```
68+
69+
## Troubleshooting
70+
71+
- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).
72+
- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags.
73+
74+
## Next steps
75+
76+
## Contributing
77+
78+
For details on contributing to this repository, see the [contributing
79+
guide][cg].
80+
81+
This project welcomes contributions and suggestions. Most contributions
82+
require you to agree to a Contributor License Agreement (CLA) declaring
83+
that you have the right to, and actually do, grant us the rights to use
84+
your contribution. For details, visit <https://cla.microsoft.com>.
85+
86+
When you submit a pull request, a CLA-bot will automatically determine
87+
whether you need to provide a CLA and decorate the PR appropriately
88+
(for example, label, comment). Follow the instructions provided by the
89+
bot. You'll only need to do this action once across all repositories
90+
using our CLA.
91+
92+
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For
93+
more information, see the [Code of Conduct FAQ][coc_faq] or contact
94+
<[email protected]> with any other questions or comments.
95+
96+
<!-- LINKS -->
97+
[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md
98+
[coc]: https://opensource.microsoft.com/codeofconduct/
99+
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/

sdk/provisioning/Azure.Provisioning.Dns/api/Azure.Provisioning.Dns.net8.0.cs

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.

sdk/provisioning/Azure.Provisioning.Dns/api/Azure.Provisioning.Dns.netstandard2.0.cs

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>Azure.Provisioning.Dns simplifies declarative resource provisioning in .NET.</Description>
5+
<Version>1.0.0-beta.1</Version>
6+
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
7+
<LangVersion>12</LangVersion>
8+
9+
<!-- Disable warning CS1591: Missing XML comment for publicly visible type or member -->
10+
<NoWarn>CS1591</NoWarn>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Azure.Provisioning" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#nullable enable
5+
6+
using Azure.Core;
7+
using Azure.Provisioning.Primitives;
8+
using Azure.Provisioning.Resources;
9+
10+
namespace Azure.Provisioning.Dns;
11+
12+
/// <summary>
13+
/// DnsARecord.
14+
/// </summary>
15+
public partial class DnsARecord : ProvisionableResource
16+
{
17+
/// <summary>
18+
/// Gets or sets the Name.
19+
/// </summary>
20+
public BicepValue<string> Name
21+
{
22+
get { Initialize(); return _name!; }
23+
set { Initialize(); _name!.Assign(value); }
24+
}
25+
private BicepValue<string>? _name;
26+
27+
/// <summary>
28+
/// Gets the Id.
29+
/// </summary>
30+
public BicepValue<ResourceIdentifier> Id
31+
{
32+
get { Initialize(); return _id!; }
33+
}
34+
private BicepValue<ResourceIdentifier>? _id;
35+
36+
/// <summary>
37+
/// Gets the SystemData.
38+
/// </summary>
39+
public SystemData SystemData
40+
{
41+
get { Initialize(); return _systemData!; }
42+
}
43+
private SystemData? _systemData;
44+
45+
/// <summary>
46+
/// The list of A records in the record set.
47+
/// </summary>
48+
public BicepList<DnsARecordInfo> ARecords
49+
{
50+
get { Initialize(); return _aRecords!; }
51+
set { Initialize(); _aRecords!.Assign(value); }
52+
}
53+
private BicepList<DnsARecordInfo>? _aRecords;
54+
55+
/// <summary>
56+
/// The TTL (time-to-live) of the records in the record set.
57+
/// </summary>
58+
public BicepValue<long> TtlInSeconds
59+
{
60+
get { Initialize(); return _ttlInSeconds!; }
61+
set { Initialize(); _ttlInSeconds!.Assign(value); }
62+
}
63+
private BicepValue<long>? _ttlInSeconds;
64+
65+
/// <summary>
66+
/// Gets or sets a reference to the parent DnsZone.
67+
/// </summary>
68+
public DnsZone? Parent
69+
{
70+
get { Initialize(); return _parent!.Value; }
71+
set { Initialize(); _parent!.Value = value; }
72+
}
73+
private ResourceReference<DnsZone>? _parent;
74+
75+
/// <summary>
76+
/// Creates a new DnsARecord.
77+
/// </summary>
78+
/// <param name="bicepIdentifier">
79+
/// The the Bicep identifier name of the DnsARecord resource. This can be
80+
/// used to refer to the resource in expressions, but is not the Azure
81+
/// name of the resource. This value can contain letters, numbers, and
82+
/// underscores.
83+
/// </param>
84+
/// <param name="resourceVersion">Version of the DnsARecord.</param>
85+
public DnsARecord(string bicepIdentifier, string? resourceVersion = default)
86+
: base(bicepIdentifier, "Microsoft.Network/dnsZones/A", resourceVersion ?? "2018-05-01")
87+
{
88+
}
89+
90+
/// <summary>
91+
/// Define all the provisionable properties of DnsARecord.
92+
/// </summary>
93+
protected override void DefineProvisionableProperties()
94+
{
95+
base.DefineProvisionableProperties();
96+
_name = DefineProperty<string>("Name", ["name"], isRequired: true);
97+
_id = DefineProperty<ResourceIdentifier>("Id", ["id"], isOutput: true);
98+
_systemData = DefineModelProperty<SystemData>("SystemData", ["systemData"], isOutput: true);
99+
_parent = DefineResource<DnsZone>("Parent", ["parent"], isRequired: true);
100+
_aRecords = DefineListProperty<DnsARecordInfo>("ARecords", ["properties", "ARecords"]);
101+
_ttlInSeconds = DefineProperty<long>(nameof(TtlInSeconds), ["properties", "TTL"]);
102+
}
103+
104+
/// <summary>
105+
/// Supported DnsARecord resource versions.
106+
/// </summary>
107+
public static class ResourceVersions
108+
{
109+
/// <summary>
110+
/// 2018-05-01.
111+
/// </summary>
112+
public static readonly string V2018_05_01 = "2018-05-01";
113+
114+
/// <summary>
115+
/// 2017-10-01.
116+
/// </summary>
117+
public static readonly string V2017_10_01 = "2017-10-01";
118+
119+
/// <summary>
120+
/// 2017-09-01.
121+
/// </summary>
122+
public static readonly string V2017_09_01 = "2017-09-01";
123+
124+
/// <summary>
125+
/// 2016-04-01.
126+
/// </summary>
127+
public static readonly string V2016_04_01 = "2016-04-01";
128+
}
129+
130+
/// <summary>
131+
/// Creates a reference to an existing DnsARecord.
132+
/// </summary>
133+
/// <param name="bicepIdentifier">
134+
/// The the Bicep identifier name of the DnsARecord resource. This can be
135+
/// used to refer to the resource in expressions, but is not the Azure
136+
/// name of the resource. This value can contain letters, numbers, and
137+
/// underscores.
138+
/// </param>
139+
/// <param name="resourceVersion">Version of the DnsARecord.</param>
140+
/// <returns>The existing DnsARecord resource.</returns>
141+
public static DnsARecord FromExisting(string bicepIdentifier, string? resourceVersion = default) =>
142+
new(bicepIdentifier, resourceVersion) { IsExistingResource = true };
143+
}

0 commit comments

Comments
 (0)