Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docs accordingly to recent changes in azcore and armcore #15489

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions documentation/MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ client.Authorizer = authorizer

```go
credential, err := azidentity.NewClientSecretCredential("<TenantId>", "<ClientId>", "<ClientSecret>", nil)
connection := armcore.NewDefaultConnection(credential, nil)
connection := arm.NewDefaultConnection(credential, nil)
client := armresources.NewResourceGroupsClient(connection, "<SubscriptionId>")
```

Expand Down Expand Up @@ -174,11 +174,11 @@ Because of adopting Azure Core which is a shared library across all Azure SDKs,

In old version (`services/**/mgmt/**`), we use the `(autorest.Client).Sender`, `(autorest.Client).RequestInspector` and `(autorest.Client).ResponseInspector` properties in `github.com/Azure/go-autorest/autorest` module to provide customized interceptor for the HTTP traffic.

In new version (`sdk/**/arm**`), we use `(armcore.ConnectionOptions).PerCallPolicies` and `(armcore.ConnectionOptions).PerRetryPolicies` in `github.com/Azure/azure-sdk-for-go/sdk/armcore` module instead to inject customized policy to the pipeline.
In new version (`sdk/**/arm**`), we use `(arm.ConnectionOptions).PerCallPolicies` and `(arm.ConnectionOptions).PerRetryPolicies` in `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package instead to inject customized policy to the pipeline.

### Custom HTTP Client

Similar to the customized policy, there are changes regarding how the custom HTTP client is configured as well. You can now use the `(armcore.ConnectionOptions).HTTPClient` option in `github.com/Azure/azure-sdk-for-go/sdk/armcore` module to use your own implementation of HTTP client and plug in what they need into the configuration.
Similar to the customized policy, there are changes regarding how the custom HTTP client is configured as well. You can now use the `(arm.ConnectionOptions).HTTPClient` option in `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package to use your own implementation of HTTP client and plug in what they need into the configuration.

**In old version (`services/**/mgmt/**`)**
```go
Expand All @@ -191,7 +191,7 @@ client.Sender = &httpClient

```go
httpClient := NewYourOwnHTTPClient{}
connection := armcore.NewConnection(credential, &armcore.ConnectionOptions{
connection := arm.NewConnection(credential, &arm.ConnectionOptions{
HTTPClient: &httpClient,
})
client := armresources.NewResourceGroupsClient(connection, "<SubscriptionId>")
Expand Down
23 changes: 11 additions & 12 deletions documentation/new-version-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ go get github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute
We also recommend installing other packages for authentication and core functionalities :

```sh
go get github.com/Azure/azure-sdk-for-go/sdk/armcore
go get github.com/Azure/azure-sdk-for-go/sdk/azcore
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
go get github.com/Azure/azure-sdk-for-go/sdk/to
Expand All @@ -108,18 +107,18 @@ For more details on how authentication works in `azidentity`, please see the doc
Connecting to Azure
-------------------

Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack.
Once you have a credential, create a connection to the desired ARM endpoint. The `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack.

```go
con := armcore.NewDefaultConnection(cred, nil)
con := arm.NewDefaultConnection(cred, nil)
```

For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore).
For more information on ARM connections, 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).

Creating a Resource Management Client
-------------------------------------

Once you have a connection to ARM, you will need to decide what service to use and create a client to connect to that service. In this section, we will use `Compute` as our target service. The Compute modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. You will need to create one or more clients to access the APIs you require using your `armcore.Connection`.
Once you have a connection to ARM, you will need to decide what service to use and create a client to connect to that service. In this section, we will use `Compute` as our target service. The Compute modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. You will need to create one or more clients to access the APIs you require using your `arm.Connection`.

To show an example, we will create a client to manage Virtual Machines. The code to achieve this task would be:

Expand Down Expand Up @@ -158,7 +157,7 @@ Example: Creating a Resource Group
```go
import (
"contexts"
"github.com/Azure/azure-sdk-for-go/sdk/armcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/resources/armresources"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/to"
Expand All @@ -178,7 +177,7 @@ var (

***Write a function to create a resource group***
```go
func createResourceGroup(ctx context.Context, connection *armcore.Connection) (armresources.ResourceGroupResponse, error) {
func createResourceGroup(ctx context.Context, connection *arm.Connection) (armresources.ResourceGroupResponse, error) {
rgClient := armresources.NewResourceGroupsClient(connection, subscriptionId)

param := armresources.ResourceGroup{
Expand All @@ -196,7 +195,7 @@ func main() {
if err != nil {
log.Fatalf("authentication failure: %+v", err)
}
conn := armcore.NewDefaultConnection(cred, &armcore.ConnectionOptions{
conn := arm.NewDefaultConnection(cred, &arm.ConnectionOptions{
Logging: azcore.LogOptions{
IncludeBody: true,
},
Expand All @@ -218,7 +217,7 @@ Example: Managing Resource Groups
***Update a resource group***

```go
func updateResourceGroup(ctx context.Context, connection *armcore.Connection) (armresources.ResourceGroupResponse, error) {
func updateResourceGroup(ctx context.Context, connection *arm.Connection) (armresources.ResourceGroupResponse, error) {
rgClient := armresources.NewResourceGroupsClient(connection, subscriptionId)

update := armresources.ResourceGroupPatchable{
Expand All @@ -233,7 +232,7 @@ func updateResourceGroup(ctx context.Context, connection *armcore.Connection) (a
***List all resource groups***

```go
func listResourceGroups(ctx context.Context, connection *armcore.Connection) ([]*armresources.ResourceGroup, error) {
func listResourceGroups(ctx context.Context, connection *arm.Connection) ([]*armresources.ResourceGroup, error) {
rgClient := armresources.NewResourceGroupsClient(connection, subscriptionId)

pager := rgClient.List(nil)
Expand All @@ -252,7 +251,7 @@ func listResourceGroups(ctx context.Context, connection *armcore.Connection) ([]
***Delete a resource group***

```go
func deleteResourceGroup(ctx context.Context, connection *armcore.Connection) error {
func deleteResourceGroup(ctx context.Context, connection *arm.Connection) error {
rgClient := armresources.NewResourceGroupsClient(connection, subscriptionId)

poller, err := rgClient.BeginDelete(ctx, resourceGroupName, nil)
Expand All @@ -273,7 +272,7 @@ func main() {
if err != nil {
log.Fatalf("authentication failure: %+v", err)
}
conn := armcore.NewDefaultConnection(cred, &armcore.ConnectionOptions{
conn := arm.NewDefaultConnection(cred, &arm.ConnectionOptions{
Logging: azcore.LogOptions{
IncludeBody: true,
},
Expand Down