-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Azure.ResourceManager.Core readmes and samples (#21858)
* Change the accessbility to virtual for Resource.Id * Readme and sample files * Fixing links * Fixing links * Fixing links * Delete OLD README.md * Migrating to new SDK * samples rename * Update ManagingResourceGroups.md Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Addressing comments in Managing Resource Groups example * Hello World added * Update Sample1_HelloWorld.md * Delete README.md * Create README.md * Addressing HelloWorld comments * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Addressing comments in readme * Commenting relative links * Fix CI Link errors * Fixing CI errors * Snippets IDs deleted * Changing Prerequisites and Auth info * Don't use .Construct in rg example * Migration guides in future PR * Fix CI * Prerequisites * Remove Links comments temporarily * Typo in Readme * Apply suggestions from code review Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com> * Changing all links to absolute links * Spelling * Commenting not existing links * Fix CI * Typo * Update Sample1_HelloWorld.md * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com>
- Loading branch information
1 parent
aad8df1
commit bf03e2d
Showing
8 changed files
with
426 additions
and
26 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
54 changes: 54 additions & 0 deletions
54
...esourcemanager/Azure.ResourceManager.Core/docs/AuthUsingEnvironmentVariables.md
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,54 @@ | ||
Authenticate to Azure using environment variables | ||
------------- | ||
|
||
You'll need the following values to authenticate to Azure: | ||
|
||
- **Subscription ID** | ||
- **Client ID** | ||
- **Client Secret** | ||
- **Tenant ID** | ||
|
||
## Obtaining the values | ||
|
||
These values can be obtained from the [portal](https://portal.azure.com/) with the following instructions: | ||
|
||
### Get Subscription ID | ||
|
||
1. Log in to your Azure account. | ||
2. Select **Subscriptions** in the left sidebar. | ||
3. Select the subscription to be used. | ||
4. Select **Overview**. | ||
5. Copy the Subscription ID. | ||
|
||
### Get Client ID / Client Secret / Tenant ID | ||
|
||
For information on how to get Client ID, Client Secret, and Tenant ID, see [this | ||
document](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). | ||
|
||
## Setting Environment Variables | ||
|
||
After you obtain the values, set the following environment variables: | ||
|
||
- `AZURE_CLIENT_ID` | ||
- `AZURE_CLIENT_SECRET` | ||
- `AZURE_TENANT_ID` | ||
- `AZURE_SUBSCRIPTION_ID` | ||
|
||
To set the environment variables on your development system: | ||
|
||
### Windows: | ||
|
||
_(Note: Administrator access is required)_ | ||
|
||
1. Open the **Control Panel**. | ||
2. Select **System Security** > **System**. | ||
3. Select **Advanced system settings** on the left. | ||
4. Inside the **System Properties** window, select the **Environment Variables** button. | ||
5. Select the property you'd like to change, then select the **Edit** button. If the property name isn't listed, select the **New** button. | ||
|
||
### Linux-based OS: | ||
|
||
export AZURE_CLIENT_ID="__CLIENT_ID__" | ||
export AZURE_CLIENT_SECRET="__CLIENT_SECRET__" | ||
export AZURE_TENANT_ID="__TENANT_ID__" | ||
export AZURE_SUBSCRIPTION_ID="__SUBSCRIPTION_ID__" |
78 changes: 78 additions & 0 deletions
78
sdk/resourcemanager/Azure.ResourceManager.Core/docs/CONTRIBUTING.md
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,78 @@ | ||
# Contributing | ||
|
||
Thank you for your interest in contributing to the Azure App Configuration client library. As an open source effort, we're excited to welcome feedback and contributions from the community. A great first step in sharing your thoughts and understanding where help is needed would be to take a look at the [open issues][open_issues]. | ||
|
||
Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla]. | ||
|
||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. | ||
|
||
## Code of conduct | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][code_of_conduct_faq] or contact [opencode@microsoft.com][email_opencode] with any additional questions or comments. | ||
|
||
## Getting started | ||
|
||
Before working on a contribution, it would be beneficial to familiarize yourself with the process and guidelines used for the Azure SDKs so that your submission is consistent with the project standards and is ready to be accepted with fewer changes requested. In particular, it is recommended to review: | ||
|
||
- [Azure SDK README][sdk_readme], to learn more about the overall project and processes used. | ||
- [Azure SDK Design Guidelines][sdk_design_guidelines], to understand the general guidelines for the Azure SDK across all languages and platforms. | ||
- [Azure SDK Contributing Guide][sdk_contributing], for information about how to onboard and contribute to the overall Azure SDK ecosystem. | ||
|
||
## Azure SDK Design Guidelines for .NET | ||
|
||
These libraries follow the [Azure SDK Design Guidelines for .NET][sdk_design_guidelines_dotnet] and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features in the [Azure.Core README][sdk_dotnet_code_readme]. | ||
|
||
## Public API changes | ||
|
||
To update [`Azure.Data.AppConfiguration.netstandard2.0.cs`][azconfig_api] after making changes to the public API, execute [`./eng/scripts/Export-API.ps1`][azconfig_export_api]. | ||
|
||
## Testing | ||
|
||
### Frameworks | ||
|
||
We use [NUnit 3][nunit] as our testing framework. | ||
|
||
[Azure.Core.TestFramework's testing framework][core_tests] provides a set of reusable primitives that simplify writing tests for new Azure SDK libraries. | ||
|
||
### Sync/Async testing | ||
|
||
We expose all of our APIs with both sync and async variants. To avoid writing each of our tests twice, we automatically rewrite our async API calls into their sync equivalents. Simply write your tests using only async APIs and call `InstrumentClient` on any of our client objects. The test framework will wrap the client with a proxy that forwards everything to the sync overloads. Please note that a number of our helpers will automatically instrument clients they provide you. Visual Studio's test runner will show `*TestClass(True)` for the async variants and `*TestClass(False)` for the sync variants. | ||
|
||
### Recorded tests | ||
|
||
Our testing framework supports recording service requests made during a unit test so they can be replayed later. You can set the `AZURE_TEST_MODE` environment variable to `Playback` to run previously recorded tests, `Record` to record or re-record tests, and `Live` to run tests against the live service. | ||
|
||
Properly supporting recorded tests does require a few extra considerations. All random values should be obtained via `this.Recording.Random` since we use the same seed on test playback to ensure our client code generates the same "random" values each time. You can't share any state between tests or rely on ordering because you don't know the order they'll be recorded or replayed. Any sensitive values are redacted via the [`ConfigurationRecordedTestSanitizer`][tests_sanitized]. | ||
|
||
### Running tests | ||
|
||
The easiest way to run the tests is via Visual Studio's unit test runner. | ||
|
||
You can also run tests via the command line using `dotnet test`, but that will run tests for all supported platforms simultaneously and intermingle their output. You can run the tests for just one platform with `dotnet test -f netcoreapp2.1` or `dotnet test -f net461`. | ||
|
||
The recorded tests are run automatically on every pull request. Live tests are run nightly. Contributors with write access can ask Azure DevOps to run the live tests against a pull request by commenting `/azp run net - appconfiguration - tests` in the PR. | ||
|
||
### Samples | ||
|
||
Our samples are structured as unit tests so we can easily verify they're up to date and working correctly. These tests aren't recorded and make minimal use of test infrastructure to keep them easy to read. | ||
|
||
## Development history | ||
|
||
For additional insight and context, the development, release, and issue history for the Azure Event Hubs client library is available in read-only form, in its previous location, the [Azure App Configuration .NET repository](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/appconfiguration). | ||
|
||
<!-- LINKS --> | ||
[azconfig_root]: ../../sdk/appconfiguration | ||
[azconfig_api]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/appconfiguration/Azure.Data.AppConfiguration/api/Azure.Data.AppConfiguration.netstandard2.0.cs | ||
[azconfig_export_api]: https://github.com/Azure/azure-sdk-for-net/blob/master/eng/scripts/Export-API.ps1 | ||
[cla]: https://cla.microsoft.com | ||
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ | ||
[code_of_conduct_faq]: https://opensource.microsoft.com/codeofconduct/faq/ | ||
[core_tests]: https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/core/Azure.Core.TestFramework | ||
[nunit]: https://github.com/nunit/docs/wiki | ||
[open_issues]: https://github.com/Azure/azure-sdk-for-net/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+label%3AClient+label%3AAzConfig | ||
[sdk_readme]: https://github.com/Azure/azure-sdk | ||
[sdk_contributing]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/appconfiguration/CONTRIBUTING.md | ||
[sdk_design_guidelines]: https://azure.github.io/azure-sdk/general_introduction.html | ||
[sdk_design_guidelines_dotnet]: https://azure.github.io/azure-sdk/dotnet_introduction.html | ||
[sdk_dotnet_code_readme]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core/README.md | ||
[email_opencode]: mailto:opencode@microsoft.com |
17 changes: 17 additions & 0 deletions
17
sdk/resourcemanager/Azure.ResourceManager.Core/samples/README.md
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,17 @@ | ||
--- | ||
page_type: sample | ||
languages: | ||
- csharp | ||
products: | ||
- azure | ||
- azure-resource-manager | ||
name: Azure.ResourceManager.Core samples for .NET | ||
description: Samples for the Azure.ResourceManager.Core client library | ||
--- | ||
|
||
# Azure.ResourceManager.Core Samples | ||
|
||
- [Hello World - Getting a subscription]<--(Sample1_HelloWorld.md)--> | ||
- [Hello World - Getting a subscription async]<--(Sample1_HelloWorldAsync.md)--> | ||
- [Managing Resource Groups]<--(Sample2_ManagingResourceGroups.md)--> | ||
- [Creating a virtual network]<--(Sample3_CreatingAVirtualNetwork.md)--> |
29 changes: 29 additions & 0 deletions
29
sdk/resourcemanager/Azure.ResourceManager.Core/samples/Sample1_HelloWorld.md
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,29 @@ | ||
# Example: Getting a subscription | ||
|
||
>Note: Before getting started with the samples, make sure to go trough the [prerequisites]<--(./README.md#Prerequisites)-->. | ||
The following code shows how to get the default subscription: | ||
|
||
```csharp | ||
var armClient = new ArmClient(new DefaultAzureCredential()); | ||
Subscription subscription = armClient.DefaultSubscription; | ||
Console.WriteLine(subscription.Id); | ||
``` | ||
|
||
It's possible to get a specific subscription as follows: | ||
|
||
```csharp | ||
string subscriptionId = "db1ab6f0-4769-4b27-930e-01e2ef9c123c"; | ||
var armClient = new ArmClient(new DefaultAzureCredential()); | ||
Subscription subscription = armClient.GetSubscriptions().Get(subscriptionId); | ||
Console.WriteLine("Got subscription: " + subscription.Data.DisplayName); | ||
``` | ||
|
||
From here, it is possible to get the resource groups from the retrieved subscription: | ||
|
||
```csharp | ||
ResourceGroupContainer rgContainer = subscription.GetResourceGroups(); | ||
``` | ||
|
||
## Next stepts | ||
Take a look at the [Managing Resource Groups]<--(Sample2_ManagingResourceGroups.md)--> samples. |
Oops, something went wrong.