{"id":1257,"date":"2020-05-20T09:00:23","date_gmt":"2020-05-20T16:00:23","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=1257"},"modified":"2020-05-21T06:27:11","modified_gmt":"2020-05-21T13:27:11","slug":"csharp-notebooks","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/csharp-notebooks\/","title":{"rendered":"Run C# notebooks with Azure Cosmos DB"},"content":{"rendered":"<p>Azure Cosmos DB built-in Jupyter Notebooks support makes it easy to analyze and visualize your Azure Cosmos DB data. Notebooks are directly integrated into the Azure portal and are completely free with your Azure Cosmos DB account.<\/p>\n<p>Today, we\u2019re excited to announce new features, now in preview, to improve the developer and collaboration experience with notebooks. With our new <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/use-csharp-notebook-features-and-commands\">C# notebooks<\/a> and <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/import-github-notebooks\">integration with GitHub<\/a>, working with your Azure Cosmos DB data is now easier than ever.<\/p>\n<h3>C# notebooks<\/h3>\n<p>In addition to Python notebooks, Azure Cosmos DB now support C# notebooks. The experience is built with .NET developers in mind, so you can interactively write and run C# code, use our built-in <a href=\"https:\/\/github.com\/Azure\/azure-cosmos-dotnet-v3\">Azure Cosmos DB .NET SDK<\/a>, and import custom NuGet packages. For those looking for an easy way to get started, try out our C# or Python notebook quickstart experience to run operations against Azure Cosmos DB, all within the Azure portal.<\/p>\n<h4>Run C# code interactively<\/h4>\n<p>In this example, we initialize a new instance of <span style=\"font-family: 'courier new', courier, monospace;\">CosmosClient<\/span>, passing in the built-in account context. Then, we create a new database and container, which appear in the resource tree.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif1-1.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1305\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif1-1.gif\" alt=\"Image NotebooksBlogPost Gif1\" width=\"1922\" height=\"794\" \/><\/a><\/p>\n<h4>Visualize your data<\/h4>\n<p>To visualize your data, simply put a variable in the last line of your code and run the cell. If it&#8217;s a <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/system.collections\">collection of items<\/a>, we&#8217;ll automatically open <a href=\"https:\/\/github.com\/nteract\/data-explorer\">nteract data explorer<\/a>, an open source visualization tool that we&#8217;ve built into the notebook. With nteract, you can view your data in a table format. You can also use pre-built visualizations for ad-hoc exploration or analysis, no code required.<\/p>\n<p>Below, we&#8217;re building a bar chart view of the results from an Azure Cosmos DB query.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif2_bog.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1304\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif2_bog.gif\" alt=\"Image NotebooksBlogPost Gif2 bog\" width=\"1922\" height=\"930\" \/><\/a><\/p>\n<h4>Use built-in magic commands<\/h4>\n<p>Notebooks come with many built-in features to help you work with your Azure Cosmos DB data. Over the past few months, we\u2019ve added and improved our notebook magic commands that help you do common operations against Azure Cosmos DB.<\/p>\n<p>For example, use the %%upload command to quickly upload an array of JSON objects to any container your Azure Cosmos DB account.<\/p>\n<h2><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif3_upload.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1303\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif3_upload.gif\" alt=\"Image NotebooksBlogPost Gif3 upload\" width=\"1306\" height=\"626\" \/><\/a><\/h2>\n<h3>Connect your notebooks workspace to GitHub<\/h3>\n<p>We\u2019ve heard from many of you that while Azure Cosmos DB makes it easy to work with notebooks, you\u2019d like an easier way to collaborate and share notebooks with others.<\/p>\n<p>With our new integration with GitHub, you can directly connect your notebooks workspace to your GitHub account. Import your repositories and notebooks into your workspace to view, edit, and run your notebooks. When you\u2019re done, save and push directly to GitHub, all conveniently from within Data Explorer.<\/p>\n<p>We support both public and private repos and branches to enable common developer workflows, based on your feedback.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif4-Copy.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1301\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/05\/NotebooksBlogPost_Gif4-Copy.gif\" alt=\"Connect notebooks workspace to GitHub and run a notebook in a branch\" width=\"1422\" height=\"702\" \/><\/a><\/p>\n<h3>Get started<\/h3>\n<p>Follow our\u00a0<a href=\"https:\/\/aka.ms\/cosmos-enable-notebooks\">documentation<\/a>\u00a0to enable notebooks on your Azure Cosmos DB account. Try out a Python or C# notebook with one of our built-in samples in the in the <a href=\"https:\/\/cosmos.azure.com\/\">Azure Cosmos Explorer<\/a>\u00a0or Data Explorer. <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/import-github-notebooks\">Connect your notebooks workspace to GitHub<\/a> to work with notebooks from your public or private repositories.<\/p>\n<p>Share your favorite notebooks with the community by sending them to the\u00a0<a href=\"https:\/\/github.com\/Azure-Samples\/cosmos-notebooks\">Azure Cosmos DB notebooks GitHub repo<\/a>. We\u2019d love to hear your feedback and see your notebooks built on Azure Cosmos DB!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re excited to announce new features in the preview of Azure Comsos DB Jupyter Notebooks. With our new C# notebooks and integration with GitHub, working with your Azure Cosmos DB data is now easier than ever.<\/p>\n","protected":false},"author":592,"featured_media":1261,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[12,13,1310],"tags":[1311,1219,1312],"class_list":["post-1257","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcements","category-news","category-notebooks","tag-github","tag-jupyter-notebooks","tag-python"],"acf":[],"blog_post_summary":"<p>We\u2019re excited to announce new features in the preview of Azure Comsos DB Jupyter Notebooks. With our new C# notebooks and integration with GitHub, working with your Azure Cosmos DB data is now easier than ever.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/1257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/592"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=1257"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/1257\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/1261"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=1257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=1257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=1257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}