This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
Перейти к файлу
Ahmet Alp Balkan 3535c92e81 Fix typo in ListHostedServiceResponse 2015-05-18 15:00:55 -07:00
core MSOpenTech → Azure 2015-04-29 17:42:38 -07:00
management Fix typo in ListHostedServiceResponse 2015-05-18 15:00:55 -07:00
storage Godoc fixes for package 2015-05-16 09:44:34 -07:00
.travis.yml management: Initial golint fixes (godoc remaining) 2015-05-14 16:22:51 -07:00
LICENSE move LICENSE file 2015-04-28 18:49:55 -07:00
README.md Update README.md 2015-05-15 13:31:57 -07:00

README.md

Azure SDK for Go

This project provides various Golang packages that makes it easy to consume and manage Microsoft Azure Services.

GoDoc Build Status

Installation

Usage

Read Godoc of the package at: http://godoc.org/github.com/Azure/azure-sdk-for-go/management

Download publish settings file from https://manage.windowsazure.com/publishsettings.

Example: Create a Linux VM

package main

import (
    "fmt"

    "github.com/Azure/azure-sdk-for-go/management"
    "github.com/Azure/azure-sdk-for-go/management/hostedservice"
    "github.com/Azure/azure-sdk-for-go/management/virtualmachine"
    "github.com/Azure/azure-sdk-for-go/management/vmutils"
)

func main() {
    dnsName := "test-vm-from-go"
    storageAccount := "mystorageaccount"
    location := "West US"
    vmSize := "Small"
    vmImage := "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04-LTS-amd64-server-20140724-en-us-30GB"
    userName := "testuser"
    userPassword := "Test123"

    client, err := management.ClientFromPublishSettingsFile("path/to/downloaded.publishsettings", "")
    if err != nil {
        panic(err)
    }

    // create hosted service
    requestId, err := hostedservice.NewClient(client).CreateHostedService(dnsName, location, "", dnsName, "")
    if err != nil {
        panic(err)
    }
    err = client.WaitAsyncOperation(requestId)
    if err != nil {
        panic(err)
    }

    // create virtual machine
    role, err := vmutils.NewVmConfiguration(dnsName, vmSize)
    if err != nil {
        panic(err)
    }
    vmutils.ConfigureDeploymentFromPlatformImage(&role,
        vmImage, fmt.Sprintf("http://%s.blob.core.windows.net/sdktest/%s.vhd", storageAccount, dnsName), "")
    vmutils.ConfigureForLinux(&role, dnsName, userName, userPassword)
    vmutils.ConfigureWithPublicSSH(&role)

    requestId, err = virtualmachine.NewClient(client).CreateDeployment(role, dnsName)
    if err != nil {
        panic(err)
    }
    err = client.WaitAsyncOperation(requestId)
    if err != nil {
        panic(err)
    }
}

License

This project is published under Apache 2.0 License.