shemke2002

AzureDBManager

Jul 11th, 2025
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | Source Code | 0 0
  1. using UnityEngine;
  2. using Microsoft.Azure.Cosmos;
  3. using UnityEngine.Networking; // Ensure you have the Azure Cosmos DB SDK installed
  4.  
  5. public class AzureDBManager : Singleton<AzureDBManager>
  6. {
  7.     string cosmosUrl = "https://elimushop.documents.azure.com:443/"; // Replace with your Cosmos DB URL
  8.     string cosmosKey = "e7VOarh1TWrIoqqIg6GXUdR2pTdYaHZsYZIyxVbHER6gqlaFWcQKMfoCaRxWW7Zhuw55QkpzYUpHACDb8qof7A==";
  9.     string databaseName = "elimushopDB"; // Replace with your database name
  10.  
  11.     CosmosClient cosmosClient;
  12.     Database database;
  13.     protected override void Awake()
  14.     {
  15.         base.Awake();
  16.         InitializeDB();
  17.     }
  18.     public void InitializeDB()
  19.     {
  20.         cosmosClient = new CosmosClient(cosmosUrl, cosmosKey); // Mono
  21.         database = cosmosClient.GetDatabase(databaseName);
  22.        
  23.         Debug.Log("Intialized DB!");
  24.     }
  25.     // Access the containers
  26.     // Create Items, Read Items, Update Items, Delete Items, etc.
  27.     public Container GetClassContainer()
  28.     {
  29.         return database.GetContainer("class"); // Replace with your container name
  30.     }
  31.     public Container GetUserProfilesContainer()
  32.     {
  33.         return database.GetContainer("userProfiles"); // Replace with your container name
  34.     }
  35.     public Container GetUserProgressContainer()
  36.     {
  37.         return database.GetContainer("userProgress"); // Replace with your container name
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment