1
1
---
2
2
title : Azure Provisioning client library for .NET
3
3
keywords : Azure, dotnet, SDK, API, Azure.Provisioning, provisioning
4
- ms.date : 07/14 /2025
4
+ ms.date : 08/01 /2025
5
5
ms.topic : reference
6
6
ms.devlang : dotnet
7
7
ms.service : provisioning
8
8
---
9
- # Azure Provisioning client library for .NET - version 1.2.1
9
+ # Azure Provisioning client library for .NET - version 1.3.0
10
10
11
11
12
12
Azure.Provisioning makes it easy to declaratively specify Azure infrastructure natively in .NET.
@@ -31,6 +31,150 @@ dotnet add package Azure.Provisioning
31
31
32
32
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.
33
33
34
+ ## Examples
35
+
36
+ ### Create Basic Infrastructure
37
+
38
+ This example demonstrates how to create basic Azure infrastructure using the Azure Provisioning framework, including a storage account with blob services and output values.
39
+
40
+ ``` C# Snippet:ProvisioningBasic
41
+ Infrastructure infra = new ();
42
+
43
+ // Create a storage account and blob resources
44
+ StorageAccount storage =
45
+ new (nameof (storage ), StorageAccount .ResourceVersions .V2023_01_01 )
46
+ {
47
+ Kind = StorageKind .StorageV2 ,
48
+ Sku = new StorageSku { Name = StorageSkuName .StandardLrs },
49
+ IsHnsEnabled = true ,
50
+ AllowBlobPublicAccess = false
51
+ };
52
+ infra .Add (storage );
53
+ blobs = new (nameof (blobs )) { Parent = storage };
54
+ infra .Add (blobs );
55
+
56
+ // Grab the endpoint
57
+ endpoint = new ProvisioningOutput (" blobs_endpoint" , typeof (string )) { Value = storage .PrimaryEndpoints .BlobUri };
58
+ infra .Add (endpoint );
59
+ ```
60
+
61
+ ### Create A Container App Environment
62
+
63
+ This example shows how to create a complete container application environment with managed identity, container registry, log analytics workspace, and container app environment with the Aspire dashboard.
64
+
65
+ ``` C# Snippet:ProvisioningContainerApp
66
+ Infrastructure infra = new ();
67
+
68
+ ProvisioningParameter principalId = new (nameof (principalId ), typeof (string )) { Value = " " };
69
+ infra .Add (principalId );
70
+
71
+ ProvisioningParameter tags = new (nameof (tags ), typeof (object )) { Value = new BicepDictionary <string >() };
72
+ infra .Add (tags );
73
+
74
+ UserAssignedIdentity mi =
75
+ new (nameof (mi ))
76
+ {
77
+ Tags = tags ,
78
+ };
79
+ infra .Add (mi );
80
+
81
+ ContainerRegistryService acr =
82
+ new (nameof (acr ))
83
+ {
84
+ Sku = new ContainerRegistrySku () { Name = ContainerRegistrySkuName .Basic },
85
+ Tags = tags ,
86
+ Identity =
87
+ new ManagedServiceIdentity
88
+ {
89
+ ManagedServiceIdentityType = ManagedServiceIdentityType .SystemAssignedUserAssigned ,
90
+ UserAssignedIdentities =
91
+ {
92
+ // TODO: Decide if we want to invest in a less janky way to use expressions as keys
93
+ { BicepFunction .Interpolate ($" {mi .Id }" ).Compile ().ToString (), new UserAssignedIdentityDetails () }
94
+ }
95
+ }
96
+ };
97
+ infra .Add (acr );
98
+
99
+ RoleAssignment pullAssignment = acr .CreateRoleAssignment (ContainerRegistryBuiltInRole .AcrPull , mi );
100
+ infra .Add (pullAssignment );
101
+
102
+ OperationalInsightsWorkspace law =
103
+ new (nameof (law ))
104
+ {
105
+ Sku = new OperationalInsightsWorkspaceSku () { Name = OperationalInsightsWorkspaceSkuName .PerGB2018 },
106
+ Tags = tags ,
107
+ };
108
+ infra .Add (law );
109
+
110
+ ContainerAppManagedEnvironment cae =
111
+ new (nameof (cae ))
112
+ {
113
+ WorkloadProfiles =
114
+ {
115
+ new ContainerAppWorkloadProfile ()
116
+ {
117
+ Name = " consumption" ,
118
+ WorkloadProfileType = " Consumption"
119
+ }
120
+ },
121
+ AppLogsConfiguration =
122
+ new ContainerAppLogsConfiguration ()
123
+ {
124
+ Destination = " log-analytics" ,
125
+ LogAnalyticsConfiguration = new ContainerAppLogAnalyticsConfiguration ()
126
+ {
127
+ CustomerId = law .CustomerId ,
128
+ SharedKey = law .GetKeys ().PrimarySharedKey ,
129
+ }
130
+ },
131
+ Tags = tags ,
132
+ };
133
+ infra .Add (cae );
134
+
135
+ RoleAssignment contribAssignment = cae .CreateRoleAssignment (AppContainersBuiltInRole .Contributor , mi );
136
+ infra .Add (contribAssignment );
137
+
138
+ // Hack in the Aspire Dashboard as a literal since there's no
139
+ // management plane library support for dotNetComponents yet
140
+ BicepLiteral aspireDashboard =
141
+ new (
142
+ new ResourceStatement (
143
+ " aspireDashboard" ,
144
+ new StringLiteralExpression (" Microsoft.App/managedEnvironments/dotNetComponents@2024-02-02-preview" ),
145
+ new ObjectExpression (
146
+ new PropertyExpression (" name" , " aspire-dashboard" ),
147
+ new PropertyExpression (" parent" , new IdentifierExpression (cae .BicepIdentifier )),
148
+ new PropertyExpression (" properties" ,
149
+ new ObjectExpression (
150
+ new PropertyExpression (" componentType" , new StringLiteralExpression (" AspireDashboard" )))))));
151
+ infra .Add (aspireDashboard );
152
+
153
+ infra .Add (new ProvisioningOutput (" MANAGED_IDENTITY_CLIENT_ID" , typeof (string )) { Value = mi .ClientId });
154
+ infra .Add (new ProvisioningOutput (" MANAGED_IDENTITY_NAME" , typeof (string )) { Value = mi .Name });
155
+ infra .Add (new ProvisioningOutput (" MANAGED_IDENTITY_PRINCIPAL_ID" , typeof (string )) { Value = mi .PrincipalId });
156
+ infra .Add (new ProvisioningOutput (" LOG_ANALYTICS_WORKSPACE_NAME" , typeof (string )) { Value = law .Name });
157
+ infra .Add (new ProvisioningOutput (" LOG_ANALYTICS_WORKSPACE_ID" , typeof (string )) { Value = law .Id });
158
+ infra .Add (new ProvisioningOutput (" AZURE_CONTAINER_REGISTRY_ENDPOINT" , typeof (string )) { Value = acr .LoginServer });
159
+ infra .Add (new ProvisioningOutput (" AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID" , typeof (string )) { Value = mi .Id });
160
+ infra .Add (new ProvisioningOutput (" AZURE_CONTAINER_APPS_ENVIRONMENT_NAME" , typeof (string )) { Value = cae .Name });
161
+ infra .Add (new ProvisioningOutput (" AZURE_CONTAINER_APPS_ENVIRONMENT_ID" , typeof (string )) { Value = cae .Id });
162
+ infra .Add (new ProvisioningOutput (" AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN" , typeof (string )) { Value = cae .DefaultDomain });
163
+ ```
164
+
165
+ ### Create A Resource Group At Subscription Scope
166
+
167
+ This example demonstrates creating a resource group at the subscription scope, which is useful when you need to manage resource groups themselves as part of your infrastructure.
168
+
169
+ ``` C# Snippet:ProvisioningResourceGroup
170
+ // Create a new infra group scoped to our subscription and add
171
+ // the resource group
172
+ Infrastructure infra = new () { TargetScope = DeploymentScope .Subscription };
173
+
174
+ ResourceGroup rg = new (" rg_test" , " 2024-03-01" );
175
+ infra .Add (rg );
176
+ ```
177
+
34
178
## Troubleshooting
35
179
36
180
- File an issue via [ GitHub Issues] ( https://github.com/Azure/azure-sdk-for-net/issues ) .
@@ -59,7 +203,7 @@ more information, see the [Code of Conduct FAQ][coc_faq] or contact
59
203
< [email protected] > with any other questions or comments.
60
204
61
205
<!-- LINKS -->
62
- [ cg ] : https://github.com/Azure/azure-sdk-for-net/blob/Azure.Provisioning_1.2.1 /sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md
206
+ [ cg ] : https://github.com/Azure/azure-sdk-for-net/blob/Azure.Provisioning_1.3.0 /sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md
63
207
[ coc ] : https://opensource.microsoft.com/codeofconduct/
64
208
[ coc_faq ] : https://opensource.microsoft.com/codeofconduct/faq/
65
209
0 commit comments