Skip to content

Commit f032564

Browse files
Add Examples sections to Azure Provisioning libraries to fix README validation (Azure#51443)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ArcturusZhang <[email protected]>
1 parent 0e74a2f commit f032564

File tree

50 files changed

+1311
-53
lines changed

Some content is hidden

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

50 files changed

+1311
-53
lines changed

eng/.docsettings.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,32 +140,9 @@ known_content_issues:
140140
- ['sdk/extension-wcf/Microsoft.CoreWCF.Azure.StorageQueues/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
141141
- ['sdk/extension-wcf/Microsoft.WCF.Azure.StorageQueues/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
142142

143-
- ['sdk/provisioning/Azure.Provisioning.AppService/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
144-
- ['sdk/provisioning/Azure.Provisioning.Sql/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
145-
- ['sdk/provisioning/Azure.Provisioning.ServiceBus/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
146-
- ['sdk/provisioning/Azure.Provisioning.Redis/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
147-
- ['sdk/provisioning/Azure.Provisioning/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
148-
- ['sdk/provisioning/Azure.Provisioning.EventGrid/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
149-
- ['sdk/provisioning/Azure.Provisioning.SignalR/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
150-
- ['sdk/provisioning/Azure.Provisioning.OperationalInsights/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
151-
- ['sdk/provisioning/Azure.Provisioning.Storage/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
152143
- ['sdk/provisioning/Azure.Provisioning.KubernetesConfiguration/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
153-
- ['sdk/provisioning/Azure.Provisioning.CosmosDB/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
154-
- ['sdk/provisioning/Azure.Provisioning.EventHubs/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
155-
- ['sdk/provisioning/Azure.Provisioning.CognitiveServices/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
156-
- ['sdk/provisioning/Azure.Provisioning.WebPubSub/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
157-
- ['sdk/provisioning/Azure.Provisioning.PostgreSql/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
158-
- ['sdk/provisioning/Azure.Provisioning.AppContainers/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
159-
- ['sdk/provisioning/Azure.Provisioning.KeyVault/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
160-
- ['sdk/provisioning/Azure.Provisioning.ContainerRegistry/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
161-
- ['sdk/provisioning/Azure.Provisioning.AppConfiguration/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
162-
- ['sdk/provisioning/Azure.Provisioning.Search/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
163144
- ['sdk/provisioning/Azure.Provisioning.Kubernetes/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
164-
- ['sdk/provisioning/Azure.Provisioning.Communication/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
165-
- ['sdk/provisioning/Azure.Provisioning.ApplicationInsights/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
166-
- ['sdk/provisioning/Azure.Provisioning.ContainerService/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
167145
- ['sdk/provisioning/Azure.Provisioning.Deployment/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
168-
- ['sdk/provisioning/Azure.Provisioning.RedisEnterprise/README.md', 'https://github.com/Azure/azure-sdk-tools/issues/404']
169146

170147
# .net climbs upwards. placing these to prevent assigning readmes to the wrong project
171148
package_indexing_exclusion_list:

sdk/provisioning/Azure.Provisioning.AppConfiguration/README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Azure.Provisioning.AppConfiguration client library for .NET
1+
# Azure Provisioning AppConfiguration client library for .NET
22

33
Azure.Provisioning.AppConfiguration simplifies declarative resource provisioning in .NET.
44

@@ -22,6 +22,54 @@ dotnet add package Azure.Provisioning.AppConfiguration
2222

2323
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.
2424

25+
## Examples
26+
27+
### Create a Basic AppConfiguration Resource
28+
29+
This example demonstrates how to create an App Configuration store with a feature flag, based on the [Azure quickstart template](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.appconfiguration/app-configuration-store-ff/main.bicep).
30+
31+
```C# Snippet:AppConfigurationStoreFF
32+
Infrastructure infra = new();
33+
34+
ProvisioningParameter featureFlagKey =
35+
new(nameof(featureFlagKey), typeof(string))
36+
{
37+
Value = "FeatureFlagSample",
38+
Description = "Specifies the key of the feature flag."
39+
};
40+
infra.Add(featureFlagKey);
41+
42+
AppConfigurationStore configStore =
43+
new(nameof(configStore), AppConfigurationStore.ResourceVersions.V2022_05_01)
44+
{
45+
SkuName = "Standard",
46+
};
47+
infra.Add(configStore);
48+
49+
ProvisioningVariable flag =
50+
new(nameof(flag), typeof(object))
51+
{
52+
Value =
53+
new BicepDictionary<object>
54+
{
55+
{ "id", featureFlagKey },
56+
{ "description", "A simple feature flag." },
57+
{ "enabled", true }
58+
}
59+
};
60+
infra.Add(flag);
61+
62+
AppConfigurationKeyValue featureFlag =
63+
new(nameof(featureFlag), AppConfigurationKeyValue.ResourceVersions.V2022_05_01)
64+
{
65+
Parent = configStore,
66+
Name = BicepFunction.Interpolate($".appconfig.featureflag~2F{featureFlagKey}"),
67+
ContentType = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8",
68+
Value = BicepFunction.AsString(flag)
69+
};
70+
infra.Add(featureFlag);
71+
```
72+
2573
## Troubleshooting
2674

2775
- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).

sdk/provisioning/Azure.Provisioning.AppConfiguration/tests/BasicAppConfigurationTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public async Task CreateAppConfigAndFeatureFlag()
2020
await test.Define(
2121
ctx =>
2222
{
23+
#region Snippet:AppConfigurationStoreFF
2324
Infrastructure infra = new();
2425

2526
ProvisioningParameter featureFlagKey =
@@ -59,6 +60,7 @@ await test.Define(
5960
Value = BicepFunction.AsString(flag)
6061
};
6162
infra.Add(featureFlag);
63+
#endregion
6264

6365
return infra;
6466
})

sdk/provisioning/Azure.Provisioning.AppContainers/README.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Azure.Provisioning.AppContainers client library for .NET
1+
# Azure Provisioning AppContainers client library for .NET
22

33
Azure.Provisioning.AppContainers simplifies declarative resource provisioning in .NET.
44

@@ -22,6 +22,93 @@ dotnet add package Azure.Provisioning.AppContainers
2222

2323
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.
2424

25+
## Examples
26+
27+
### Create A Container App
28+
29+
This example demonstrates how to create a Container App with log analytics workspace and managed environment, based on the [Azure quickstart template](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.app/container-app-create/main.bicep).
30+
31+
```C# Snippet:AppContainerBasic
32+
Infrastructure infra = new();
33+
34+
ProvisioningParameter containerImage =
35+
new(nameof(containerImage), typeof(string))
36+
{
37+
Value = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest",
38+
Description = "Specifies the docker container image to deploy."
39+
};
40+
infra.Add(containerImage);
41+
42+
OperationalInsightsWorkspace logAnalytics =
43+
new(nameof(logAnalytics))
44+
{
45+
Sku = new OperationalInsightsWorkspaceSku { Name = OperationalInsightsWorkspaceSkuName.PerGB2018 }
46+
};
47+
infra.Add(logAnalytics);
48+
49+
ContainerAppManagedEnvironment env =
50+
new(nameof(env))
51+
{
52+
AppLogsConfiguration =
53+
new ContainerAppLogsConfiguration
54+
{
55+
Destination = "log-analytics",
56+
LogAnalyticsConfiguration = new ContainerAppLogAnalyticsConfiguration
57+
{
58+
CustomerId = logAnalytics.CustomerId,
59+
SharedKey = logAnalytics.GetKeys().PrimarySharedKey,
60+
}
61+
},
62+
};
63+
infra.Add(env);
64+
65+
ContainerApp app =
66+
new(nameof(app))
67+
{
68+
ManagedEnvironmentId = env.Id,
69+
Configuration =
70+
new ContainerAppConfiguration
71+
{
72+
Ingress =
73+
new ContainerAppIngressConfiguration
74+
{
75+
External = true,
76+
TargetPort = 80,
77+
AllowInsecure = false,
78+
Traffic =
79+
{
80+
new ContainerAppRevisionTrafficWeight
81+
{
82+
IsLatestRevision = true,
83+
Weight = 100
84+
}
85+
}
86+
},
87+
},
88+
Template =
89+
new ContainerAppTemplate
90+
{
91+
RevisionSuffix = "firstrevision",
92+
Scale = new ContainerAppScale { MinReplicas = 1, MaxReplicas = 3 },
93+
Containers =
94+
{
95+
new ContainerAppContainer
96+
{
97+
Name = "test",
98+
Image = containerImage,
99+
Resources =
100+
new AppContainerResources
101+
{
102+
Cpu = (BicepExpression?)BicepFunction.ParseJson("0.5"),
103+
Memory = "1Gi"
104+
}
105+
}
106+
}
107+
}
108+
};
109+
infra.Add(app);
110+
```
111+
25112
## Troubleshooting
26113

27114
- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).

sdk/provisioning/Azure.Provisioning.AppContainers/tests/BasicAppContainersTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public async Task CreateContainerApp()
2121
await test.Define(
2222
ctx =>
2323
{
24+
#region Snippet:AppContainerBasic
2425
Infrastructure infra = new();
2526

2627
ProvisioningParameter containerImage =
@@ -99,6 +100,7 @@ await test.Define(
99100
}
100101
};
101102
infra.Add(app);
103+
#endregion
102104

103105
return infra;
104106
})

sdk/provisioning/Azure.Provisioning.AppService/README.md

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Azure.Provisioning.AppService client library for .NET
1+
# Azure Provisioning AppService client library for .NET
22

33
Azure.Provisioning.AppService simplifies declarative resource provisioning in .NET.
44

@@ -22,6 +22,109 @@ dotnet add package Azure.Provisioning.AppService
2222

2323
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.
2424

25+
## Examples
26+
27+
### Create a Basic Function App
28+
29+
This example demonstrates how to create a Function App with required dependencies including storage account and application insights, based on the [Azure quickstart template](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.web/function-app-create-dynamic/main.bicep).
30+
31+
```C# Snippet:AppServiceBasic
32+
Infrastructure infra = new();
33+
34+
StorageAccount storage =
35+
new(nameof(storage))
36+
{
37+
Sku = new StorageSku { Name = StorageSkuName.StandardLrs },
38+
Kind = StorageKind.Storage,
39+
EnableHttpsTrafficOnly = true,
40+
IsDefaultToOAuthAuthentication = true
41+
};
42+
infra.Add(storage);
43+
44+
AppServicePlan hostingPlan =
45+
new(nameof(hostingPlan), "2021-03-01")
46+
{
47+
Sku =
48+
new AppServiceSkuDescription
49+
{
50+
Tier = "Dynamic",
51+
Name = "Y1"
52+
}
53+
};
54+
infra.Add(hostingPlan);
55+
56+
ApplicationInsightsComponent appInsights =
57+
new(nameof(appInsights))
58+
{
59+
Kind = "web",
60+
ApplicationType = ApplicationInsightsApplicationType.Web,
61+
RequestSource = ComponentRequestSource.Rest
62+
};
63+
infra.Add(appInsights);
64+
65+
ProvisioningVariable funcAppName =
66+
new(nameof(funcAppName), typeof(string))
67+
{
68+
Value = BicepFunction.Concat("functionApp-", BicepFunction.GetUniqueString(BicepFunction.GetResourceGroup().Id))
69+
};
70+
infra.Add(funcAppName);
71+
72+
WebSite functionApp =
73+
new(nameof(functionApp), WebSite.ResourceVersions.V2023_12_01)
74+
{
75+
Name = funcAppName,
76+
Kind = "functionapp",
77+
Identity = new ManagedServiceIdentity { ManagedServiceIdentityType = ManagedServiceIdentityType.SystemAssigned },
78+
AppServicePlanId = hostingPlan.Id,
79+
IsHttpsOnly = true,
80+
SiteConfig =
81+
new SiteConfigProperties
82+
{
83+
FtpsState = AppServiceFtpsState.FtpsOnly,
84+
MinTlsVersion = AppServiceSupportedTlsVersion.Tls1_2,
85+
AppSettings =
86+
{
87+
new AppServiceNameValuePair
88+
{
89+
Name = "AzureWebJobsStorage",
90+
Value = BicepFunction.Interpolate($"DefaultEndpointsProtocol=https;AccountName={storage.Name};EndpointSuffix=core.windows.net;AccountKey={storage.GetKeys()[0].Unwrap().Value}")
91+
},
92+
new AppServiceNameValuePair
93+
{
94+
Name = "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
95+
Value = BicepFunction.Interpolate($"DefaultEndpointsProtocol=https;AccountName={storage.Name};EndpointSuffix=core.windows.net;AccountKey={storage.GetKeys()[0].Unwrap().Value}")
96+
},
97+
new AppServiceNameValuePair
98+
{
99+
Name = "WEBSITE_CONTENTSHARE",
100+
Value = BicepFunction.ToLower(funcAppName)
101+
},
102+
new AppServiceNameValuePair
103+
{
104+
Name = "FUNCTIONS_EXTENSION_VERSION",
105+
Value = "~4"
106+
},
107+
new AppServiceNameValuePair
108+
{
109+
Name = "WEBSITE_NODE_DEFAULT_VERSION",
110+
Value = "~14"
111+
},
112+
new AppServiceNameValuePair
113+
{
114+
Name = "FUNCTIONS_WORKER_RUNTIME",
115+
Value = "dotnet"
116+
},
117+
new AppServiceNameValuePair
118+
{
119+
Name = "APPINSIGHTS_INSTRUMENTATIONKEY",
120+
Value = appInsights.InstrumentationKey
121+
}
122+
}
123+
}
124+
};
125+
infra.Add(functionApp);
126+
```
127+
25128
## Troubleshooting
26129

27130
- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).

sdk/provisioning/Azure.Provisioning.AppService/tests/BasicAppServiceTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public async Task CreateBasicFunctionApp()
2424
await test.Define(
2525
ctx =>
2626
{
27+
#region Snippet:AppServiceBasic
2728
Infrastructure infra = new();
2829

2930
StorageAccount storage =
@@ -118,6 +119,7 @@ await test.Define(
118119
}
119120
};
120121
infra.Add(functionApp);
122+
#endregion
121123

122124
return infra;
123125
})

sdk/provisioning/Azure.Provisioning.ApplicationInsights/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Azure.Provisioning.ApplicationInsights client library for .NET
1+
# Azure Provisioning ApplicationInsights client library for .NET
22

33
Azure.Provisioning.ApplicationInsights simplifies declarative resource provisioning in .NET.
44

@@ -22,6 +22,28 @@ dotnet add package Azure.Provisioning.ApplicationInsights
2222

2323
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.
2424

25+
## Examples
26+
27+
### Create a Basic Application Insights Component
28+
29+
This example demonstrates how to create an Application Insights component for application performance monitoring, based on the [Azure quickstart template](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.web/function-app-create-dynamic/main.bicep).
30+
31+
```C# Snippet:ApplicationInsightsBasic
32+
Infrastructure infra = new();
33+
34+
ApplicationInsightsComponent appInsights =
35+
new(nameof(appInsights))
36+
{
37+
Kind = "web",
38+
ApplicationType = ApplicationInsightsApplicationType.Web,
39+
RequestSource = ComponentRequestSource.Rest
40+
};
41+
infra.Add(appInsights);
42+
43+
infra.Add(new ProvisioningOutput("appInsightsName", typeof(string)) { Value = appInsights.Name });
44+
infra.Add(new ProvisioningOutput("appInsightsKey", typeof(string)) { Value = appInsights.InstrumentationKey });
45+
```
46+
2547
## Troubleshooting
2648

2749
- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).

0 commit comments

Comments
 (0)