Giter VIP home page Giter VIP logo

cosmosdbstudio's Introduction

Warning

This project is not currently under active development. I have very little spare time to work on this, and since I don't currently use Cosmos DB, I have little incentive to continue improving this app. You've been warned! Feel free to use it anyway if it works for you.

Cosmos DB Studio

Application icon

A tool to browse and query Azure Cosmos DB databases.

Screenshot

I created this app out of frustration with the completely broken experience in Azure Storage Explorer (which is basically the same as Data Explorer in the Azure portal, with the same limitations and many more bugs).

It's a bit rough around the edges, and some features are still missing, but it's mostly functional.

Requirements

You will need Windows 10 version 1803 or later. It might work on older Windows versions if you build from source (you will need the .NET Core 3.1 SDK), but the packaged application requires Windows 10, and I didn't take any step to ensure it would work on other versions.

Installation

From the Windows Store

The app is available on the Windows Store.

Sideloading

  1. Download the package (appxbundle file) from the release page.
  2. If it's the first time you install the application, you will need to trust the app certificate:
    1. Open the Properties dialog for the package file.
    2. Go to the Digital signatures tab.
    3. Select the signature from the list and click Details.
    4. Click View certificate.
    5. Click Install certificate.
    6. Select Local machine as the store location, and accept the UAC dialog.
    7. Choose Place all certificates in the following store, click Browse, and select Trusted People.
    8. Click Next, then Finish
  3. Enable developer mode to allow sideloading, if not already done:
    1. Open Windows settings
    2. Go to Update and security
    3. Go to the For developers section
    4. Enable Developer mode
  4. Double click the package and follow the instructions.

Getting started

  1. Start the app
  2. Right click in the left pane to add a Cosmos DB account. Enter a name, the account endpoint and key, and an optional folder to organize your account. (If you have a Cosmos DB connection string in the clipboard, the endpoint and key will be filled automatically)
  3. Expand the account node in the treeview to select a database (or create a new one from the context menu)
  4. Expand the database node in the treeview to select a container (or create a new one from the context menu)
  5. Right-click the container node and select "New query sheet". This will create a new SQL query sheet for this container.
  6. Enter a valid Cosmos DB SQL query and hit Ctrl-Enter. It will select the whole query and execute it.
  7. The results will appear in the bottom pane

Tip: you can have multiple queries in the same query sheet, just separate them with an empty line.

cosmosdbstudio's People

Contributors

dependabot[bot] avatar ricardopinedathen avatar rmt2021 avatar thomaslevesque avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cosmosdbstudio's Issues

Support insert/update/delete statements for batch operations

As a pseudo-SQL language, parsed and translated to :

  • document creation for insert statements
  • query-then-update for update statements
  • query-then-delete for delete operations

e.g.:

insert into c { name: 'foo', price: 123.0 }
update c set c.answer = 42 where c.question = 'life, the universe and everything'
delete c where c.expirationDate < '2019-01-01T00:00:00'

(exact syntax tbd)

Request options should be supported, as specified in #2 (e.g. partition key, pre/post triggers...)

Bonus: optionally, create a temporary stored procedure to perform the operations atomically in a transaction (would fail if execution exceeds the provisioned throughput, e.g. if too many documents are affected)

Handle the transient errors

Bug Description

When using the Cosmos DB Studio, it is possible to encounter transient errors, and the application cannot handle such errors (like 503 Server Busy) now. When the transient error happens, the application would even have an inconsistent view with the real service. For instance, if a database deletion request (use the SDK API DeleteAsync to delete database A) arrived the Cosmos DB server but the response never returned or a 408 Timeout returned, then the database name ("A") will still remain in the list of Cosmos DB Studio, but user cannot operate on that database anymore (because there is no database A in the Cosmos server anymore).

Discussion

As this document shown, there are some transient error codes (408, 410, 429, 449 and 503) that we can retry on:
https://docs.microsoft.com/en-us/azure/cosmos-db/sql/conceptual-resilient-sdk-applications#should-my-application-retry-on-errors

Additional Context

We are willing to discuss the transient error handlings and write a PR for this issue.

Support request options in query editor

Maybe with YAML comments or directives above each statement, e.g.:

# partitionKey: "blah"
select * from c where c.name = 'foo'

Global options that apply to the whole query sheet would be useful as well

Options to support:

  • partition key
  • cross partition query (maybe by default if no partition key specified)
  • pre/post triggers (for update/delete/insert statements described in #8)
  • collection (assuming database-scoped query sheets are supported)
  • database (assuming account-scoped query sheets are supported)

Support modification or deletion of documents in query results

The query results should show the documents separately, with an option to modify or delete them.

Problem: how do we know if the results contain actual raw documents, not projections? Testing for the presence of system properties such as _self or _rid isn't fool proof, since they can be included in a projection.

Add support for Serverless accounts

Some features (e.g. create/edit container or database) seem to be broken when connecting to a Cosmos account in Serverless mode. Need to investigate.

App will not open if the sheets folder has been moved

I have two sheets I leave open in Studio when I shut it down. After shutting down, I moved the folder where the sheets were being stored. The next time I attempted to open Studio, nothing happened. I checked the event log and found the load failed because it couldn't find those two sheets.

The work-around was to move the folder back to its original location, open Studio, and do a Save As for each sheet, moving it to its new location.

Here is the message from the event log:

  • 1026 0 2 0 0 0x80000000000000 51998 Application DESKTOP-EQGSM0V
  • Application: CosmosDBStudio.exe CoreCLR Version: 4.700.20.36602 .NET Core Version: 3.1.7 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Dev\SQL Queries\Cosmos Queries\Last 20 events.cdbsqs'. at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks) at System.IO.File.InternalReadAllText(String path, Encoding encoding) at System.IO.File.ReadAllText(String path) at CosmosDBStudio.Services.Implementation.QueryPersistenceService.Load(String path) at CosmosDBStudio.ViewModel.MainWindowViewModel.LoadWorkspace() at CosmosDBStudio.ViewModel.MainWindowViewModel..ctor(IViewModelFactory viewModelFactory, IMessenger messenger, IDialogService dialogService, IQueryPersistenceService queryPersistenceService, AccountCommands accountCommands) at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.b__0(ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at CosmosDBStudio.Program.Main(String[] args)

Automatically select the current statement on Execute

Currently the statement to be executed has to be selected in the editor. Automatically finding the start and end of the current statement (based on the cursor position) and selecting it would make the workflow smoother.

Better error messages for queries

Errors returned by Cosmos DB are pure cr*p. Here's an exemple of the body of an error response (formatted):

{
        "code": "BadRequest",
        "message": "Gateway Failed to Retrieve Query Plan: Message: {\"errors\":[{\"severity\":\"Error\",\"location\":{\"start\":36,\"end\":36},\"code\":\"SC1002\",\"message\":\"Syntax error, unexpected end-of-file.\"}]}\r\nActivityId: 3d7a2504-ea2b-4075-a957-0ca8e4ae05f8, Microsoft.Azure.Documents.Common/2.11.0, Microsoft.Azure.Documents.Common/2.11.0"
}

The message content is plain text, with some JSON in the middle of it. It's unreadable, and the actual error data is difficult to extract.

It would be nice to parse this mess, display a clear error message, and show error squiggles in the editor at the specified location.

Error while launching CosmosDb Studio

Hi,
I tested your project and greatly appreciated it : many thanks !

A colleague of mine wanted to used it, but faced an error message while launching CosmosDb Studio be it installed through the App store or by sideloading.
His Windows 10 version is 19041, so should be okay with your requirements.

Is there any kind of redistributable that we should be aware of to make it run properly ?

MicrosoftTeams-image (5)

Cache trees and remember position in "pick a container"

Switching containers via "pick a container" is slower than it should be, because you have to drill down through the accounts and databases to find your container, but there are usually (often?) loaded on-demand.

It seems that the app would be faster if all "pick a container" trees and the tree on the left-hand side of the program shared a common state, so that if a node is loaded in one it does not need to be reloaded in the other. Like in SSMS, a "refresh" option would be available on each node for if/when needed.

Once this is available, the "pick a container" tree could be unfolded on opening to the current location.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.