From 438c7e5773181af70055fcdcc7e99fd94d547f9d Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Wed, 18 Aug 2021 07:45:00 -0700 Subject: [PATCH] Fixed bugs in Resource Group demo code (#15301) - [ ] The purpose of this PR is explained in this or a referenced issue. - [ ] The PR does not update generated files. - These files are managed by the codegen framework at [Azure/autorest.go][]. - [ ] Tests are included and/or updated for code changes. - [ ] Updates to [CHANGELOG.md][] are included. - [ ] MIT license headers are included in each file. [Azure/autorest.go]: https://github.com/Azure/autorest.go [CHANGELOG.md]: https://github.com/Azure/azure-sdk-for-go/blob/main/CHANGELOG.md --- documentation/new-version-quickstart.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/documentation/new-version-quickstart.md b/documentation/new-version-quickstart.md index 7de746f29138..a6652ead60bf 100644 --- a/documentation/new-version-quickstart.md +++ b/documentation/new-version-quickstart.md @@ -168,10 +168,11 @@ import ( ***Define some global variables*** ```go var ( - ctx = context.Background() - subscriptionId = os.Getenv("AZURE_SUBSCRIPTION_ID") - location = "westus2" - resourceGroupName = "resourceGroupName" + ctx = context.Background() + subscriptionId = os.Getenv("AZURE_SUBSCRIPTION_ID") + location = "westus2" + resourceGroupName = "resourceGroupName" + interval = 5 * time.Second ) ``` @@ -283,13 +284,13 @@ func main() { if err != nil { log.Fatalf("cannot create resource group: %+v", err) } - log.Printf("Resource Group %s created", *resourceGroup.ID) + log.Printf("Resource Group %s created", *resourceGroup.ResourceGroup.ID) updatedRG, err := updateResourceGroup(ctx, conn) if err != nil { log.Fatalf("cannot update resource group: %+v", err) } - log.Printf("Resource Group %s updated", *updatedRG.ID) + log.Printf("Resource Group %s updated", *updatedRG.ResourceGroup.ID) rgList, err := listResourceGroups(ctx, conn) if err != nil { @@ -312,20 +313,21 @@ Due to the complexity of this scenario, please [click here](https://aka.ms/azsdk Long Running Operations ----------------------- -In the samples above, you might notice that some operations has a ``Begin`` prefix (for example, ``BeginDelete``). This indicates the operation is a Long-Running Operation (In short, LRO). For resource managment libraries, this kind of operation is quite common since certain resource operations may take a while to finish. When you need to use those LROs, you will need to use a poller and keep polling for the result until it is done. To illustrate this pattern, here is an example +In the samples above, you might notice that some operations have a ``Begin`` prefix (for example, ``BeginDelete``). This indicates the operation is a Long-Running Operation (LRO). For resource management libraries, this kind of operation is quite common since certain resource operations may take a while to finish. When you need to use those LROs, you will need to use a poller and keep polling for the result until it is done. To illustrate this pattern, here is an example ```go poller, err := client.BeginCreate(context.Background(), "resource_identifier", "additonal_parameter") if err != nil { // handle error... } -resp, err = poller.PollUntilDone(context.Background(), 5*time.Second) +resp, err = poller.PollUntilDone(context.Background(), 5 * time.Second) if err != nil { // handle error... } fmt.Printf("LRO done") // dealing with `resp` ``` + Note that you will need to pass a polling interval to ```PollUntilDone``` and tell the poller how often it should try to get the status. This number is usually small but it's best to consult the [Azure service documentation](https://docs.microsoft.com/azure/?product=featured) on best practices and recommdend intervals for your specific use cases. For more advanced usage of LRO and design guidelines of LRO, please visit [this documentation here](https://azure.github.io/azure-sdk/golang_introduction.html#methods-invoking-long-running-operations) @@ -364,4 +366,4 @@ our CLA. This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact - with any additional questions or comments. +[opencode@microsoft.com](mailto:opencode@microsoft.com) with any questions or comments.