using System;
using Azure.Storage.Blobs;

namespace squirrowse.db
{
    public class Bloob
    {
        private readonly BlobServiceClient _blobServiceClient;

        public BlobContainerClient Container;

        public Bloob()
        {
            _blobServiceClient =
                new BlobServiceClient(
                    "DefaultEndpointsProtocol=https;AccountName=squirrowse;AccountKey=34EmEpHYAoCybkXwq365I+5Vd4+zoqGfakTBj/1+rh3Ef9vng386JpgbAc5BKGuoTlNdDnMEyX9K4q73j5qlaQ==;EndpointSuffix=core.windows.net");
            Container = CreateImgBloob("squirrowseimg");
        }

        private BlobContainerClient CreateImgBloob(string name)
        {
            try
            {
                return _blobServiceClient.CreateBlobContainer(name);
            }
            catch (Exception)
            {
                return _blobServiceClient.GetBlobContainerClient(name);
            }
        }
    }
}