(subscriptionID, tenantID, clientID, clientSecret string)
| 61 | ) |
| 62 | |
| 63 | func initializeAzureClients(subscriptionID, tenantID, clientID, clientSecret string) { |
| 64 | oAuthConfig, err := adal.NewOAuthConfig(defaultActiveDirectoryEndpoint, tenantID) |
| 65 | if err != nil { |
| 66 | log.Fatalf("Cannot get oAuth configuration: %v", err) |
| 67 | } |
| 68 | |
| 69 | token, err := adal.NewServicePrincipalToken(*oAuthConfig, clientID, clientSecret, defaultResourceManagerEndpoint) |
| 70 | if err != nil { |
| 71 | log.Fatalf("Cannot get service principal token: %v", err) |
| 72 | } |
| 73 | |
| 74 | groupsClient = resources.NewGroupsClient(subscriptionID) |
| 75 | groupsClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 76 | |
| 77 | accountsClient = storage.NewAccountsClient(subscriptionID) |
| 78 | accountsClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 79 | |
| 80 | virtualNetworksClient = network.NewVirtualNetworksClient(subscriptionID) |
| 81 | virtualNetworksClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 82 | |
| 83 | subnetsClient = network.NewSubnetsClient(subscriptionID) |
| 84 | subnetsClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 85 | |
| 86 | publicIPAddressesClient = network.NewPublicIPAddressesClient(subscriptionID) |
| 87 | publicIPAddressesClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 88 | |
| 89 | interfacesClient = network.NewInterfacesClient(subscriptionID) |
| 90 | interfacesClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 91 | |
| 92 | virtualMachinesClient = compute.NewVirtualMachinesClient(subscriptionID) |
| 93 | virtualMachinesClient.Authorizer = autorest.NewBearerAuthorizer(token) |
| 94 | |
| 95 | } |
| 96 | |
| 97 | func createResourceGroup(resourceGroupName, location string) *resources.Group { |
| 98 | fmt.Printf("Creating resource group in %s\n", location) |
no outgoing calls
no test coverage detected