This sample code in the Go SDK creates a virtual machine by deploying an ARM template. It requires you to include the clientId and clientSecret from the service principal.
This sample code from Go SDK creates a virtual machine using the Go SDK for Azure. It requires a subscription ID but not a service principal (client ID, client secret). It also does not automatically create service principals.
I thought that creating a virtual machine requires a service principal, but the GO SDK sample is able to create a virtual machine without specifying a service principal. What am I missing about service principals and virtual machines?
It uses newdefaultazurecredential, this class retrieves authentication information from the environment (e.g. azure cli, environment variables) - View documentation
func connectionAzure() (azcore.TokenCredential, error) { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { return nil, err } return cred, nil }
The above is the detailed content of Go SDK for Azure How to create a virtual machine without a service principal?. For more information, please follow other related articles on the PHP Chinese website!