func resourceArmStorageContainerCreate(d *schema.ResourceData, meta interface{}) error {
	armClient := meta.(*ArmClient)

	resourceGroupName := d.Get("resource_group_name").(string)
	storageAccountName := d.Get("storage_account_name").(string)

	blobClient, accountExists, err := armClient.getBlobStorageClientForStorageAccount(resourceGroupName, storageAccountName)
	if err != nil {
		return err
	}
	if !accountExists {
		return fmt.Errorf("Storage Account %q Not Found", storageAccountName)
	}

	name := d.Get("name").(string)

	var accessType storage.ContainerAccessType
	if d.Get("container_access_type").(string) == "private" {
		accessType = storage.ContainerAccessType("")
	} else {
		accessType = storage.ContainerAccessType(d.Get("container_access_type").(string))
	}

	log.Printf("[INFO] Creating container %q in storage account %q.", name, storageAccountName)
	_, err = blobClient.CreateContainerIfNotExists(name, accessType)
	if err != nil {
		return fmt.Errorf("Error creating container %q in storage account %q: %s", name, storageAccountName, err)
	}

	d.SetId(name)
	return resourceArmStorageContainerRead(d, meta)
}
// resourceAzureStorageContainerCreate does all the necessary API calls to
// create the storage container on Azure.
func resourceAzureStorageContainerCreate(d *schema.ResourceData, meta interface{}) error {
	azureClient := meta.(*Client)
	storName := d.Get("storage_service_name").(string)

	blobClient, err := azureClient.getStorageServiceBlobClient(storName)
	if err != nil {
		return err
	}

	log.Println("[INFO] Creating storage container on Azure.")
	name := d.Get("name").(string)
	accessType := storage.ContainerAccessType(d.Get("container_access_type").(string))
	err = blobClient.CreateContainer(name, accessType)
	if err != nil {
		return fmt.Errorf("Failed to create storage container on Azure: %s", err)
	}

	d.SetId(name)
	return resourceAzureStorageContainerRead(d, meta)
}
func (c *Controller) CreateServiceInstance(w http.ResponseWriter, r *http.Request) {
	fmt.Println("Create Service Instance...")

	statusCode, err := authentication(r)
	if err != nil {
		w.WriteHeader(statusCode)
		return
	}

	var instance model.ServiceInstance
	instance.DashboardUrl = "http://dashbaord_url"

	err = utils.ProvisionDataFromRequest(r, &instance)
	if err != nil {
		fmt.Println("Failed to provision data from request")
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	acceptsIncomplete := r.URL.Query().Get("accepts_incomplete")
	if acceptsIncomplete != "true" {
		fmt.Println("Only asynchronous provisioning is supported")
		response := make(map[string]string)
		response["error"] = "AsyncRequired"
		response["description"] = "This service plan requires client support for asynchronous service operations."
		utils.WriteResponse(w, 422, response)
		return
	}

	serviceInstanceGuid := utils.ExtractVarsFromRequest(r, "service_instance_guid")
	instance.Id = serviceInstanceGuid

	var containerAccessType storageclient.ContainerAccessType
	switch instance.Parameters.(type) {
	case map[string]interface{}:
		param := instance.Parameters.(map[string]interface{})

		if param["container_access_type"] != nil {
			containerAccessType = storageclient.ContainerAccessType(param["container_access_type"].(string))
		} else {
			containerAccessType = storageclient.ContainerAccessTypePrivate
		}
	default:
		containerAccessType = storageclient.ContainerAccessTypePrivate
	}

	resourceGroupName, storageAccountName, err := c.serviceClient.CreateInstance(serviceInstanceGuid, instance.Parameters)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	instance.ResourceGroupName = resourceGroupName
	instance.StorageAccountName = storageAccountName
	instance.ContainerAccessType = containerAccessType

	instance.State = "in progress"
	instance.Description = "creating service instance..."

	c.instanceMap[instance.Id] = &instance
	err = utils.MarshalAndRecord(c.instanceMap, conf.DataPath, conf.ServiceInstancesFileName)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	response := model.CreateServiceInstanceResponse{
		DashboardUrl: instance.DashboardUrl,
	}
	utils.WriteResponse(w, http.StatusAccepted, response)
}