Hybrid-Compute-GO-ManagedDisks

Dernière mise à jour : 29/03/2019
Modifier sur GitHub

These samples demonstrate how to create Virtual Machines with managed disks 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-ManagedDisks.git
    
  4. Create a service principal using a certificate 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 AZS_ARM_ENDPOINT={your AzureStack Resource Manager Endpoint}
    export AZS_TENANT_ID={your tenant id}
    export AZS_CLIENT_ID={your client id}
    export AZS_CLIENT_SECRET={your client secret}
    export AZS_CERT_PATH={your service principal certificate path}
    export AZS_SUBSCRIPTION_ID={your subscription id}
    export AZS_LOCATION={your resource location}
    
    
  6. Note that in order to run this sample on ADFS environments, use adfs as the value of AZS_TENANT_ID environment variable.

  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.