Pomiń nawigację

Hybrid-Compute-GO-Create-VM

autor: Ali Nikravesh
Ostatnia aktualizacja: 16.01.2019
Edytuj w witrynie GitHub

These samples demonstrate how to create Virtual Machines using the Azure SDK for Go on Azure Stack. The code provided shows how to do the following:

  • Create a resource group
  • Create a virtual network
  • Create a security group
  • Create a public IP
  • Create a network interface
  • Create a storage account
  • Create a virtual machine

To see the code to perform these operations, check out the main() function in app.go. Each operation is clearly labeled with a comment and a print function.

Running this sample

  1. If you don't already have it, install Golang.

  2. Install Go SDK and its dependencies, install Go SDK

  3. Clone the repository.

    git clone https://github.com/Azure-Samples/Hybrid-Compute-Go-Create-VM.git
    
  4. Create a service principal to work against AzureStack. Make sure your service principal has contributor/owner role on your subscription.

  5. Fill in and export these environment variables into your current shell.

    export ACTIVE_DIRECTORY_ENDPOINT={your active directory endpoint}
    export ACTIVE_DIRECTORY_RESOURCE_ID={your active directory resource ID}
    export ARM_ENDPOINT={your AzureStack Resource Manager Endpoint}
    export AZURE_TENANT_ID={your tenant id}
    export AZURE_CLIENT_ID={your client id}
    export AZURE_CLIENT_SECRET={your client secret}
    export AZURE_SUBSCRIPTION_ID={your subscription id}
    export AZURE_STORAGE_ENDPOINT_SUFFIX={your storage endpoint suffix}
    export AZURE_LOCATION={your resource location}
    
    
  6. Note that in order to run this sample, WindowsServer 2012-R2-Datacenter image must be present in AzureStack market place. These can be either downloaded from Azure or added to Platform Image Repository.

  7. Run the sample.

    go run app.go
    

More information

Here are some helpful links:

If you don't have a Microsoft Azure subscription you can get a FREE trial account here.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.