Reputation: 53
I wanted to perform the following task using GO SDK for which I couldn't found any good example:
package main
import (
"fmt"
"github.com/Azure/go-autorest/autorest/azure/auth"
)
func main() {
authorizer, err := auth.NewAuthorizerFromEnvironment()
not sure it is the correct one. Anything else we need to set up here.
How to use it in GO SDK using the client?
Upvotes: 0
Views: 302
Reputation: 31424
Of course, you can use the environment to authenticate and already set all the necessary environment variables. Then there is no problem with the samples.
If you're not familiar with the necessary environment variables, I recommend you use file-based authentication. It's more simple.
You can simply create the VM client with your select authorizer:
vmClient := compute.NewVirtualMachinesClient("subcriptionID")
This VM client will help you start and stop the VM as you want.
Upvotes: 1