Skip to content

Commit 4c80e9b

Browse files
author
SDKAuto
committed
CodeGen from PR 33408 in Azure/azure-rest-api-specs
Merge 4ea799dfa8332f2a92553b5fbe953e8ac4051439 into fb3217991ff57b5760525aeba1a0670bfe0880fa
1 parent 3a817f8 commit 4c80e9b

File tree

14 files changed

+1368
-1390
lines changed

14 files changed

+1368
-1390
lines changed

sdk/batch/azbatch/CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Release History
22

3-
## 0.1.0 (Unreleased)
3+
## 0.1.0 (2025-05-01)
4+
### Other Changes
45

5-
### Features Added
6-
* Initial release
6+
The package of `github.com/Azure/azure-sdk-for-go/sdk/batch/azbatch` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html).
7+
8+
To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt).

sdk/batch/azbatch/LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Microsoft Corporation.
3+
Copyright (c) Microsoft Corporation. All rights reserved.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE
21+
SOFTWARE.

sdk/batch/azbatch/README.md

Lines changed: 55 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,90 @@
1-
# Azure Batch client module for Go
1+
# Azure Batch Module for Go
22

3-
Azure Batch allows users to run large-scale parallel and high-performance computing (HPC) batch jobs efficiently in Azure.
3+
The `azbatch` module provides operations for working with Azure Batch.
44

5-
Use this module to:
5+
[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/batch/azbatch)
66

7-
- Create and manage Batch jobs and tasks
8-
- View and perform operations on nodes in a Batch pool
7+
# Getting started
98

10-
## Getting started
9+
## Prerequisites
1110

12-
### Install the module
11+
- an [Azure subscription](https://azure.microsoft.com/free/)
12+
- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).)
1313

14-
Install the `azbatch` and `azidentity` modules with `go get`:
14+
## Install the package
1515

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).
16+
This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management.
2617

27-
### Authenticate the client
18+
Install the Azure Batch module:
2819

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.
20+
```sh
21+
go get github.com/Azure/azure-sdk-for-go/sdk/batch/azbatch
22+
```
3023

31-
## Key concepts
24+
## Authorization
3225

33-
[Azure Batch Overview](https://learn.microsoft.com/azure/batch/batch-technical-overview)
26+
When creating a client, you will need to provide a credential for authenticating with Azure Batch. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more.
3427

35-
## Examples
28+
```go
29+
cred, err := azidentity.NewDefaultAzureCredential(nil)
30+
```
3631

37-
See the [package documentation][pkgsite] for code samples.
32+
For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity).
3833

39-
## Troubleshooting
34+
## Client Factory
4035

41-
Please see [Troubleshooting common batch issues](https://learn.microsoft.com/troubleshoot/azure/hpc/batch/welcome-hpc-batch).
36+
Azure Batch module consists of one or more clients. We provide a client factory which could be used to create any client in this module.
4237

43-
### Error Handling
38+
```go
39+
clientFactory, err := azbatch.NewClientFactory(<subscription ID>, cred, nil)
40+
```
4441

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.
42+
You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore).
4643

4744
```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-
}
45+
options := arm.ClientOptions {
46+
ClientOptions: azcore.ClientOptions {
47+
Cloud: cloud.AzureChina,
48+
},
5849
}
50+
clientFactory, err := azbatch.NewClientFactory(<subscription ID>, cred, &options)
5951
```
6052

61-
### Logging
53+
## Clients
6254

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:
55+
A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory.
6456

6557
```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)
58+
client := clientFactory.()
7559
```
7660

77-
### Accessing `http.Response`
61+
## Fakes
7862

79-
You can access the `http.Response` returned by Azure Batch to any client method using `runtime.WithCaptureResponse`:
63+
The fake package contains types used for constructing in-memory fake servers used in unit tests.
64+
This allows writing tests to cover various success/error conditions without the need for connecting to a live service.
8065

81-
```go
82-
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
66+
Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes.
8367

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-
```
68+
## Provide Feedback
9269

93-
## Contributing
70+
If you encounter bugs or have suggestions, please
71+
[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Batch` label.
9472

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/).
73+
# Contributing
9874

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.
75+
This project welcomes contributions and suggestions. Most contributions require
76+
you to agree to a Contributor License Agreement (CLA) declaring that you have
77+
the right to, and actually do, grant us the rights to use your contribution.
78+
For details, visit [https://cla.microsoft.com](https://cla.microsoft.com).
10279

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.
80+
When you submit a pull request, a CLA-bot will automatically determine whether
81+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
82+
comment). Simply follow the instructions provided by the bot. You will only
83+
need to do this once across all repos using our CLA.
10584

106-
[pkgsite]: https://aka.ms/azsdk/go/azbatch
85+
This project has adopted the
86+
[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
87+
For more information, see the
88+
[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
89+
or contact [[email protected]](mailto:[email protected]) with any
90+
additional questions or comments.

sdk/batch/azbatch/ci.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trigger:
88
- release/*
99
paths:
1010
include:
11-
- sdk/batch/azbatch
11+
- sdk/batch/azbatch/
1212

1313
pr:
1414
branches:
@@ -19,14 +19,9 @@ pr:
1919
- release/*
2020
paths:
2121
include:
22-
- sdk/batch/azbatch
22+
- sdk/batch/azbatch/
2323

2424
extends:
2525
template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
2626
parameters:
27-
EnableRaceDetector: true
28-
Location: westus2
29-
RunLiveTests: true
30-
ServiceDirectory: batch/azbatch
31-
TimeOutInMinutes: 20
32-
UsePipelineProxy: false
27+
ServiceDirectory: 'batch/azbatch'

0 commit comments

Comments
 (0)