-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating code snippets in Samples and Readme (#22518)
* Change the accessbility to virtual for Resource.Id * Initial setup * Adding Snippets to tests\Samples * Generate snippets in markdown files * Sample 3 code snippets * Update Sample2_ManagingResourceGroups.cs * Update Snippets with generator * Fix Sample2 snippets * Delete Azure - Backup.ResourceManager.Core.Tests.csproj * Ignoring dummy subscription id tests * Adding namespaces to examples * Modify code snippets in main readme * Add ignore tags * Adding Azure.ResourceManager.Core namespace * Update code snippets * Adjust indentation * Removing auto-gen snippets for Sample3 Co-authored-by: YalinLi0312 <[email protected]> Co-authored-by: m-nash <[email protected]> Co-authored-by: m-nash <[email protected]>
- Loading branch information
1 parent
a3ffa95
commit 1cd717a
Showing
10 changed files
with
395 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
sdk/resourcemanager/Azure.ResourceManager.Core/tests/Samples/Readme.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#region Snippet:Readme_AuthClient | ||
using Azure.Identity; | ||
using Azure.ResourceManager.Core; | ||
using System; | ||
using System.Threading.Tasks; | ||
#if !SNIPPET | ||
using NUnit.Framework; | ||
|
||
namespace Azure.ResourceManager.Core.Tests.Samples | ||
{ | ||
class Readme | ||
{ | ||
[Test] | ||
[Ignore("Only verifying that the sample builds")] | ||
public void ClientAuth() | ||
{ | ||
#endif | ||
|
||
// code omitted for brevity | ||
|
||
var armClient = new ArmClient(new DefaultAzureCredential()); | ||
#endregion Snippet:Readme_AuthClient | ||
} | ||
|
||
[Test] | ||
[Ignore("Only verifying that the sample builds")] | ||
public async Task CreateRG() | ||
{ | ||
#region Snippet:Readme_CreateRG | ||
// First, initialize the ArmClient and get the default subscription | ||
var armClient = new ArmClient(new DefaultAzureCredential()); | ||
Subscription subscription = armClient.DefaultSubscription; | ||
// Now we get a ResourceGroup container for that subscription | ||
ResourceGroupContainer rgContainer = subscription.GetResourceGroups(); | ||
|
||
// With the container, we can create a new resource group with an specific name | ||
string rgName = "myRgName"; | ||
LocationData location = LocationData.WestUS; | ||
ResourceGroup resourceGroup = await rgContainer.Construct(location).CreateOrUpdateAsync(rgName); | ||
#endregion Snippet:Readme_CreateRG | ||
} | ||
|
||
[Test] | ||
[Ignore("Only verifying that the sample builds")] | ||
public async Task ListAllRG() | ||
{ | ||
#region Snippet:Readme_ListAllRG | ||
// First, initialize the ArmClient and get the default subscription | ||
var armClient = new ArmClient(new DefaultAzureCredential()); | ||
Subscription subscription = armClient.DefaultSubscription; | ||
|
||
// Now we get a ResourceGroup container for that subscription | ||
ResourceGroupContainer rgContainer = subscription.GetResourceGroups(); | ||
|
||
// With ListAsync(), we can get a list of the resources in the container | ||
AsyncPageable<ResourceGroup> response = rgContainer.ListAsync(); | ||
await foreach (ResourceGroup rg in response) | ||
{ | ||
Console.WriteLine(rg.Data.Name); | ||
} | ||
#endregion Snippet:Readme_ListAllRG | ||
} | ||
} | ||
} |
Oops, something went wrong.