message: Ensure CosmosDB database and container creation in Flask framework
diff: @@ -11,9 +11,18 @@ class SQLObj():
  url_connection = connection_key,
  auth = {'masterKey': master_key}
  )
  +
  + try:
  self.db = self.client.CreateDatabase(
  {'id': CONSTANTS['COSMOS']['DATABASE']}
  )
  + except errors.HTTPFailure as e:
  + if e.status_code == http_constants.StatusCodes.CONFLICT:
  + self.db = self.client.ReadDatabase("dbs/" + CONSTANTS['COSMOS']['DATABASE'])
  + else:
  + raise e
  +
  + try:
  self.container = self.client.CreateContainer(
  self.db['_self'],
  {
  @@ -23,6 +32,11 @@ class SQLObj():
  'offerThroughput': 400
  }
  )
  + except errors.HTTPFailure as e:
  + if e.status_code == http_constants.StatusCodes.CONFLICT:
  + self.container = self.client.ReadContainer("dbs/" + CONSTANTS['COSMOS']['DATABASE'] + "/colls/" + CONSTANTS['COSMOS']['CONTAINER'])
  + else:
  + raise e
  def get_client(self):
  return self.client
  