azureSdkForGo

package
v0.1.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2015 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

README

Azure SDK for Golang

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

Installation

go get github.com/MSOpenTech/azure-sdk-for-go
  • Install:
go install github.com/MSOpenTech/azure-sdk-for-go

Usage

Create linux VM:

package main

import (
    "fmt"
    "os"
    
    azure "github.com/MSOpenTech/azure-sdk-for-go"
    "github.com/MSOpenTech/azure-sdk-for-go/clients/vmClient"
)

func main() {
    dnsName := "test-vm-from-go"
    location := "West US"
    vmSize := "Small"
    vmImage := "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04-LTS-amd64-server-20140724-en-us-30GB"
    userName := "testuser"
    userPassword := "Test123"
    sshCert := ""
    sshPort := 22
    
    err := azure.ImportPublishSettings(SUBSCRIPTION_ID, SUBSCRIPTION_CERTIFICATE)
    if err != nil {
    	fmt.Println(err)
    	os.Exit(1)
    }
    
    vmConfig, err := vmClient.CreateAzureVMConfiguration(dnsName, vmSize, vmImage, location)
    if err != nil {
    	fmt.Println(err)
    	os.Exit(1)
    }
    
    vmConfig, err = vmClient.AddAzureLinuxProvisioningConfig(vmConfig, userName, userPassword, sshCert, sshPort)
    if err != nil {
    	fmt.Println(err)
    	os.Exit(1)
    }
    
    err = vmClient.CreateAzureVM(vmConfig, dnsName, location)
    if err != nil {
    	fmt.Println(err)
    	os.Exit(1)
    }
}

License

Apache 2.0

Documentation

Index

Constants

View Source
const (
	ParamNotSpecifiedError = "Parameter %s is not specified."
)

Variables

This section is empty.

Functions

func CheckStringParams

func CheckStringParams(url string) ([]byte, error)

func ExecuteCommand

func ExecuteCommand(command string, input []byte) ([]byte, error)

func GetPublishSettings

func GetPublishSettings() publishSettings

func ImportPublishSettings

func ImportPublishSettings(id string, certPath string) error

func ImportPublishSettingsFile

func ImportPublishSettingsFile(filePath string) error

func NewUUID

func NewUUID() (string, error)

NewUUID generates a random UUID according to RFC 4122

func SendAzureDeleteRequest

func SendAzureDeleteRequest(url string) (string, error)

func SendAzureGetRequest

func SendAzureGetRequest(url string) ([]byte, error)

func SendAzurePostRequest

func SendAzurePostRequest(url string, data []byte) (string, error)

func SendAzureRequest

func SendAzureRequest(url string, requestType string, data []byte) (*http.Response, error)

func WaitAsyncOperation

func WaitAsyncOperation(operationId string) error

Types

type AzureError

type AzureError struct {
	XMLName xml.Name `xml:"Error"`
	Code    string
	Message string
}

func (*AzureError) Error

func (e *AzureError) Error() string

type Operation

type Operation struct {
	XMLName        xml.Name `xml:"Operation"`
	ID             string
	Status         string
	HttpStatusCode string
	Error          AzureError
}

func GetOperationStatus

func GetOperationStatus(operationId string) (*Operation, error)

Directories

Path Synopsis
clients
core

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL