-
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.
- Loading branch information
Showing
5 changed files
with
304 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
# Azure Batch client library for .NET | ||
|
||
Azur Batch is a managed service that helps developers get secret simply and securely. | ||
Azure Batch allows users to run large-scale parallel and high-performance computing (HPC) batch jobs efficiently in Azure. | ||
|
||
Use the client library for to: | ||
|
||
* [Get secret](https://docs.microsoft.com/azure) | ||
* Create and manage Batch jobs and tasks | ||
* View and perform operations on nodes in a Batch pool | ||
|
||
[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] | ||
|
||
[Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/batch/Azure.Compute.Batch/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) | ||
[Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/batch/Azure.Compute.Batch/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://learn.microsoft.com/dotnet/api/overview/azure/batch?view=azure-dotnet) | [Product documentation](https://learn.microsoft.com/azure/batch/) | ||
|
||
## Getting started | ||
|
||
This section should include everything a developer needs to do to install and create their first client connection *very quickly*. | ||
|
||
### Install the package | ||
|
||
First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. | ||
|
||
Install the client library for .NET with [NuGet](https://www.nuget.org/ ): | ||
|
||
```dotnetcli | ||
|
@@ -26,21 +21,46 @@ dotnet add package Azure.Compute.Batch --prerelease | |
|
||
### Prerequisites | ||
|
||
Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: | ||
- An Azure account with an active subscription. If you don't have one, [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). | ||
|
||
> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. | ||
- A Batch account with a linked Azure Storage account. You can create the accounts by using any of the following methods: [Azure CLI](https://learn.microsoft.com/azure/batch/quick-create-cli) | [Azure portal](https://learn.microsoft.com/azure/batch/quick-create-portal) | [Bicep](https://learn.microsoft.com/azure/batch/quick-create-bicep) | [ARM template](https://learn.microsoft.com/azure/batch/quick-create-template) | [Terraform](https://learn.microsoft.com/azure/batch/quick-create-terraform). | ||
|
||
- [Visual Studio 2019](https://www.visualstudio.com/vs) or later, or [.NET 6.0](https://dotnet.microsoft.com/download/dotnet) or later, for Linux or Windows. | ||
### Authenticate the client | ||
|
||
If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. | ||
Batch account access supports two methods of authentication: Shared Key and Microsoft Entra ID. | ||
|
||
For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. | ||
We strongly recommend using Microsoft Entra ID for Batch account authentication. Some Batch capabilities require this method of authentication, including many of the security-related features discussed here. The service API authentication mechanism for a Batch account can be restricted to only Microsoft Entra ID using the [allowedAuthenticationModes](https://learn.microsoft.com/rest/api/batchmanagement/batch-account/create?view=rest-batchmanagement-2024-02-01&tabs=HTTP) property. When this property is set, API calls using Shared Key authentication will be rejected. | ||
|
||
## Key concepts | ||
#### Authenticate using Microsoft Entra ID | ||
|
||
Azure Batch provides integration with Microsoft Entra ID for identity-based authentication of requests. With Azure AD, you can use role-based access control (RBAC) to grant access to your Azure Batch resources to users, groups, or applications. The [Azure Identity library](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/identity/Azure.Identity/README.md) provides easy Microsoft Entra ID support for authentication. | ||
|
||
|
||
```C# | ||
BatchClient client = new BatchClient( | ||
new Uri("https://examplebatchaccount.eastus.batch.azure.com"), | ||
new DefaultAzureCredential()); | ||
``` | ||
|
||
#### Authenticate using Shared Key | ||
|
||
You can also use Shared Key authentication to sign into your Batch account. This method uses your Batch account access keys to authenticate Azure commands for the Batch service. You can find your batch account shared keys in the portal under the "keys" section or you can run the following [CLI command](https://learn.microsoft.com/cli/azure/batch/account/keys?view=azure-cli-latest) | ||
|
||
The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. | ||
```bash | ||
az batch account keys list --name <your-batch-account> --resource-group <your-resource-group-name> | ||
``` | ||
|
||
```C# | ||
var credential = new AzureNamedKeyCredential("examplebatchaccount", "BatchAccountKey"); | ||
BatchClient client = new BatchClient( | ||
new Uri("https://examplebatchaccount.eastus.batch.azure.com"), | ||
new credential()); | ||
``` | ||
|
||
## Key concepts | ||
|
||
Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: | ||
[Azure Batch Overview](https://learn.microsoft.com/azure/batch/batch-technical-overview) | ||
|
||
### Thread safety | ||
|
||
|
@@ -59,28 +79,21 @@ We guarantee that all client instance methods are thread-safe and independent of | |
|
||
## Examples | ||
|
||
You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/batch/Azure.Compute.Batch/). | ||
|
||
You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/batch/Azure.Compute.Batch/samples/README.md). | ||
## Troubleshooting | ||
|
||
Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. | ||
|
||
Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. | ||
|
||
If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. | ||
|
||
## Next steps | ||
|
||
* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. | ||
* If appropriate, point users to other packages that might be useful. | ||
* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. | ||
View more https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/batch/Azure.Compute.Batch/samples here for common usages of the Batch client library: [Batch Samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/batch/Azure.Compute.Batch/samples). | ||
|
||
## Contributing | ||
|
||
This is a template, but your SDK readme should include details on how to contribute code to the repo/package. | ||
This project welcomes contributions and suggestions. | ||
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 [Contributor License Agreements](https://opensource.microsoft.com/cla/). | ||
|
||
<!-- LINKS --> | ||
[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization | ||
[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide | ||
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. | ||
|
||
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/batch/Azure.Compute.Batch/README.png) | ||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments. |
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,15 @@ | ||
--- | ||
page_type: sample | ||
languages: | ||
- csharp | ||
products: | ||
- azure | ||
- azure-batch | ||
name: Azure Batch samples for .NET | ||
description: Samples for the Azure.Compute.Batch client library | ||
--- | ||
|
||
# Azure Batch SDK Samples | ||
Before starting, take a look at the Azure Batch [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/batch/Azure.Compute.Batch/README.md) for more information on how to create an Batch Account using the Azure portal/Azure CLI, and retrieving the designated endpoint and credential. | ||
|
||
- [Creating a Pool, Job, and Task](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/batch/Azure.Compute.Batch/samples/Sample1_CreatePool_Job_Task.md) |
Oops, something went wrong.