I'm trying to create a database with a program written in c #. I created a free account and created a resource of azure cosmos db. The connection to the cosmos account db is done correctly but at the time of creating the database I do not get an answer, it stays and waits. Is it possible that I need a larger subscription to do this? The code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Newtonsoft.Json;
namespace AzureApp
{
class Program
{
private const string EndpointUrl = "<endpoint>";
private const string PrimaryKey = "<privatekey>";
private DocumentClient client;
static void Main(string[] args)
{
try
{
Program p = new Program();
p.GetStartedDemo().Wait();
}
catch (DocumentClientException de)
{
Exception baseException = de.GetBaseException();
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
}
catch (Exception e)
{
Exception baseException = e.GetBaseException();
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
}
finally
{
Console.WriteLine("End of demo, press any key to exit.");
Console.ReadKey();
}
}
private async Task GetStartedDemo()
{
this.client = new DocumentClient(new Uri(EndpointUrl), PrimaryKey);
await this.client.CreateDatabaseIfNotExistsAsync(new Database { Id = "FamilyDB" });
}
private void WriteToConsoleAndPromptToContinue(string format, params object[] args)
{
Console.WriteLine(format, args);
Console.WriteLine("Press any key to continue ...");
Console.ReadKey();
}
}
}
Thanks in advance.