Skip to content

Commit 1d6e946

Browse files
authored
First preview of azbatch module (Azure#24175)
1 parent 66ccd1a commit 1d6e946

24 files changed

+26130
-0
lines changed

eng/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"Name": "azappconfig",
99
"CoverageGoal": 0.19
1010
},
11+
{
12+
"Name": "azbatch",
13+
"CoverageGoal": 0.70
14+
},
1115
{
1216
"Name": "azblob",
1317
"CoverageGoal": 0.30

sdk/batch/azbatch/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Release History
2+
3+
## 0.1.0 (Unreleased)
4+
5+
### Features Added
6+
* Initial release

sdk/batch/azbatch/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

sdk/batch/azbatch/README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Azure Batch client module for Go
2+
3+
Azure Batch allows users to run large-scale parallel and high-performance computing (HPC) batch jobs efficiently in Azure.
4+
5+
Use this module to:
6+
7+
- Create and manage Batch jobs and tasks
8+
- View and perform operations on nodes in a Batch pool
9+
10+
## Getting started
11+
12+
### Install the module
13+
14+
Install the `azbatch` and `azidentity` modules with `go get`:
15+
16+
```bash
17+
go get github.com/Azure/azure-sdk-for-go/sdk/batch/azbatch
18+
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
19+
```
20+
21+
### Prerequisites
22+
23+
- Go, version 1.18 or higher - [Install Go](https://go.dev/doc/install)
24+
- Azure subscription - [Create a free account](https://azure.microsoft.com/free)
25+
- 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).
26+
27+
### Authenticate the client
28+
29+
Azure Batch integrates with Microsoft Entra ID for identity-based authentication of requests. You can use role-based access control (RBAC) to grant access to your Azure Batch resources to users, groups, or applications. The [Azure Identity module](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity) provides types that implement Microsoft Entra ID authentication.
30+
31+
## Key concepts
32+
33+
[Azure Batch Overview](https://learn.microsoft.com/azure/batch/batch-technical-overview)
34+
35+
## Examples
36+
37+
See the [package documentation][pkgsite] for code samples.
38+
39+
## Troubleshooting
40+
41+
Please see [Troubleshooting common batch issues](https://learn.microsoft.com/troubleshoot/azure/hpc/batch/welcome-hpc-batch).
42+
43+
### Error Handling
44+
45+
All methods which send HTTP requests return `*azcore.ResponseError` when these requests fail. `ResponseError` has error details and the raw response from Key Vault.
46+
47+
```go
48+
import "github.com/Azure/azure-sdk-for-go/sdk/azcore"
49+
50+
resp, err = client.CreateJob(context.TODO(), jobContent, nil)
51+
if err != nil {
52+
var httpErr *azcore.ResponseError
53+
if errors.As(err, &httpErr) {
54+
// TODO: investigate httpErr
55+
} else {
56+
// TODO: not an HTTP error
57+
}
58+
}
59+
```
60+
61+
### Logging
62+
63+
This module uses the logging implementation in `azcore`. To turn on logging for all Azure SDK modules, set `AZURE_SDK_GO_LOGGING` to `all`. By default the logger writes to stderr. Use the `azcore/log` package to control log output. For example, logging only HTTP request and response events, and printing them to stdout:
64+
65+
```go
66+
import azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
67+
68+
// Print log events to stdout
69+
azlog.SetListener(func (_ azlog.Event, msg string) {
70+
fmt.Println(msg)
71+
})
72+
73+
// Includes only requests and responses in logs
74+
azlog.SetEvents(azlog.EventRequest, azlog.EventResponse)
75+
```
76+
77+
### Accessing `http.Response`
78+
79+
You can access the `http.Response` returned by Azure Batch to any client method using `runtime.WithCaptureResponse`:
80+
81+
```go
82+
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
83+
84+
var response *http.Response
85+
ctx := runtime.WithCaptureResponse(context.TODO(), &response)
86+
resp, err = client.CreateJob(ctx, jobContent, nil)
87+
if err != nil {
88+
// TODO: handle error
89+
}
90+
// TODO: do something with response
91+
```
92+
93+
## Contributing
94+
95+
This project welcomes contributions and suggestions.
96+
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.
97+
For details, visit [Contributor License Agreements](https://opensource.microsoft.com/cla/).
98+
99+
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).
100+
Simply follow the instructions provided by the bot.
101+
You will only need to do this once across all repos using our CLA.
102+
103+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
104+
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.
105+
106+
[pkgsite]: https://aka.ms/azsdk/go/azbatch

sdk/batch/azbatch/assets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "go",
4+
"TagPrefix": "go/batch/azbatch",
5+
"Tag": "go/batch/azbatch_8e5f9fa739"
6+
}

sdk/batch/azbatch/build.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
//go:generate tsp-client update -d
5+
//go:generate go run testdata/transform.go
6+
//go:generate goimports -w .
7+
8+
package azbatch

sdk/batch/azbatch/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
2+
trigger:
3+
branches:
4+
include:
5+
- main
6+
- feature/*
7+
- hotfix/*
8+
- release/*
9+
paths:
10+
include:
11+
- sdk/batch/azbatch
12+
13+
pr:
14+
branches:
15+
include:
16+
- main
17+
- feature/*
18+
- hotfix/*
19+
- release/*
20+
paths:
21+
include:
22+
- sdk/batch/azbatch
23+
24+
extends:
25+
template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
26+
parameters:
27+
EnableRaceDetector: true
28+
Location: westus2
29+
RunLiveTests: true
30+
ServiceDirectory: batch/azbatch
31+
TimeOutInMinutes: 20
32+
UsePipelineProxy: false

0 commit comments

Comments
 (0)