libraries/botbuilder-azure/botbuilder/azure/cosmosdb_storage.py
async def write(self, changes: Dict[str, StoreItem]):
        """Save storeitems to storage.

        :param changes:
        :return:
        """
        try:
            # check if the database and container exists and if not create
            if not self.__container_exists:
                self.__create_db_and_container()
                # iterate over the changes
            for (key, change) in changes.items():
                # store the e_tag
                e_tag = change.e_tag
                # create the new document
                doc = {'id': self.__sanitize_key(key),
                       'realId': key,
                       'document': self.__create_dict(change)
                       }
                # the e_tag will be * for new docs so do an insert
                if (e_tag == '*' or not e_tag):
                    self.client.UpsertItem(
                        database_or_Container_link=self.__container_link,
                        document=doc,
                        options={'disableAutomaticIdGeneration': True}
                        )
                # if we have an etag, do opt. concurrency replace
                elif(len(e_tag) > 0):
                    access_condition = {'type': 'IfMatch', 'condition': e_tag}
                    self.client.ReplaceItem(
                        document_link=self.__item_link(
                            self.__sanitize_key(key)),
                        new_document=doc,
                        options={'accessCondition': access_condition}
                        )
                # error when there is no e_tag
                else:
                    raise Exception('cosmosdb_storage.write(): etag missing')
        except Exception as e:
            raise e
async def write(self, changes: Dict[str, StoreItem]):
        """Save storeitems to storage.

        :param changes:
        :return:
        """
        try:
            # check if the database and container exists and if not create
            if not self.__container_exists:
                self.__create_db_and_container()
                # iterate over the changes
            for (key, change) in changes.items():
                # store the e_tag
                e_tag = change.e_tag
                # create the new document
                doc = {'id': self.__sanitize_key(key),
                       'realId': key,
                       'document': self.__create_dict(change)
                       }
                # the e_tag will be * for new docs so do an insert
                if (e_tag == '*' or not e_tag):
                    self.client.UpsertItem(
                        database_or_Container_link=self.__container_link,
                        document=doc,
                        options={'disableAutomaticIdGeneration': True}
                        )
                # if we have an etag, do opt. concurrency replace
                elif(len(e_tag) > 0):
                    access_condition = {'type': 'IfMatch', 'condition': e_tag}
                    self.client.ReplaceItem(
                        document_link=self.__item_link(
                            self.__sanitize_key(key)),
                        new_document=doc,
                        options={'accessCondition': access_condition}
                        )
                # error when there is no e_tag
                else:
                    raise Exception('cosmosdb_storage.write(): etag missing')
        except Exception as e:
            raise e
async def write ( self , changes : Dict [ str , StoreItem ] ) : try : # check if the database and container exists and if not create if not self . __container_exists : self . __create_db_and_container ( ) # iterate over the changes for ( key , change ) in changes . items ( ) : # store the e_tag e_tag = change . e_tag # create the new document doc = { 'id' : self . __sanitize_key ( key ) , 'realId' : key , 'document' : self . __create_dict ( change ) } # the e_tag will be * for new docs so do an insert if ( e_tag == '*' or not e_tag ) : self . client . UpsertItem ( database_or_Container_link = self . __container_link , document = doc , options = { 'disableAutomaticIdGeneration' : True } ) # if we have an etag, do opt. concurrency replace elif ( len ( e_tag ) > 0 ) : access_condition = { 'type' : 'IfMatch' , 'condition' : e_tag } self . client . ReplaceItem ( document_link = self . __item_link ( self . __sanitize_key ( key ) ) , new_document = doc , options = { 'accessCondition' : access_condition } ) # error when there is no e_tag else : raise Exception ( 'cosmosdb_storage.write(): etag missing' ) except Exception as e : raise e
Save storeitems to storage.

        :param changes:
        :return:
Save storeitems to storage .