Beispiel #1
0
func CreateHostedService(dnsName, location string) (string, error) {
	if len(dnsName) == 0 {
		return "", fmt.Errorf(azure.ParamNotSpecifiedError, "dnsName")
	}
	if len(location) == 0 {
		return "", fmt.Errorf(azure.ParamNotSpecifiedError, "location")
	}

	err := verifyDNSname(dnsName)
	if err != nil {
		return "", err
	}

	result, reason, err := CheckHostedServiceNameAvailability(dnsName)
	if err != nil {
		return "", err
	}
	if !result {
		return "", fmt.Errorf("%s Hosted service name: %s", reason, dnsName)
	}

	err = locationClient.ResolveLocation(location)
	if err != nil {
		return "", err
	}

	hostedServiceDeployment := createHostedServiceDeploymentConfig(dnsName, location)
	hostedServiceBytes, err := xml.Marshal(hostedServiceDeployment)
	if err != nil {
		return "", err
	}

	requestURL := azureHostedServiceListURL
	requestId, err := azure.SendAzurePostRequest(requestURL, hostedServiceBytes)
	if err != nil {
		return "", err
	}

	return requestId, nil
}
Beispiel #2
0
func CreateAzureVMConfiguration(dnsName, instanceSize, imageName, location string) (*Role, error) {
	if len(dnsName) == 0 {
		return nil, fmt.Errorf(azure.ParamNotSpecifiedError, "dnsName")
	}
	if len(instanceSize) == 0 {
		return nil, fmt.Errorf(azure.ParamNotSpecifiedError, "instanceSize")
	}
	if len(imageName) == 0 {
		return nil, fmt.Errorf(azure.ParamNotSpecifiedError, "imageName")
	}
	if len(location) == 0 {
		return nil, fmt.Errorf(azure.ParamNotSpecifiedError, "location")
	}

	err := verifyDNSname(dnsName)
	if err != nil {
		return nil, err
	}

	err = locationClient.ResolveLocation(location)
	if err != nil {
		return nil, err
	}

	err = ResolveRoleSize(instanceSize)
	if err != nil {
		return nil, err
	}

	role, err := createAzureVMRole(dnsName, instanceSize, imageName, location)
	if err != nil {
		return nil, err
	}

	return role, nil
}