public function write($sessionId, $sessionData) {
        // serialize and encode the session data.
        $serializedData = base64_encode(serialize($sessionData));

        try {
            // try to retrive the stored session entity and update it.
            $result = $this->_tableRestProxy->getEntity($this->_sessionContainer, $this->_sessionContainerPartition, $sessionId);
            $entity = $result->getEntity();

            // update data and expiry time
            $entity->setPropertyValue('data', $serializedData);
            $entity->setPropertyValue('expires', time());

            // update entity
            $this->_tableRestProxy->updateEntity($this->_sessionContainer, $entity);
        } catch (ServiceException $e) {
            // otherwise, create a new session entity to store the data.
            $entity = new Entity();

            // set partition key and use session id as the row key.
            $entity->setPartitionKey($this->_sessionContainerPartition);
            $entity->setRowKey($sessionId);
            // set data and expiry time
            $entity->addProperty('data', EdmType::STRING, $serializedData);
            $entity->addProperty('expires', EdmType::INT32, time());

            // insert the entity
            $this->_tableRestProxy->insertEntity($this->_sessionContainer, $entity);
        }
        return TRUE;
    }