-
Notifications
You must be signed in to change notification settings - Fork 74
Java SDK v4 Sample Code #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stagingBranch
Are you sure you want to change the base?
Changes from 3 commits
f763fec
e5a4af4
c3f0847
5eb8c47
7db028a
4b1d76b
07ebbf4
c846111
18f564b
ad65355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| target/ | ||
| pom.xml.tag | ||
| pom.xml.releaseBackup | ||
| pom.xml.versionsBackup | ||
| pom.xml.next | ||
| release.properties | ||
| dependency-reduced-pom.xml | ||
| buildNumber.properties | ||
| .mvn/timing.properties | ||
| # https://github.com/takari/maven-wrapper#usage-without-binary-jar | ||
| .mvn/wrapper/maven-wrapper.jar | ||
|
|
||
| # Compiled class file | ||
| *.class | ||
|
|
||
| # Log file | ||
| *.log | ||
|
|
||
| # BlueJ files | ||
| *.ctxt | ||
|
|
||
| # idea files | ||
| /.idea/ | ||
|
|
||
| # Mobile Tools for Java (J2ME) | ||
| .mtj.tmp/ | ||
|
|
||
| # Package Files # | ||
| *.jar | ||
| *.war | ||
| *.nar | ||
| *.ear | ||
| *.zip | ||
| *.tar.gz | ||
| *.rar | ||
|
|
||
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
| hs_err_pid* | ||
|
|
||
| # Eclipse project file | ||
| *.project | ||
|
|
||
| # Maven autogenerated classpath | ||
| *.classpath | ||
|
|
||
| #VSCode Directories | ||
| /*.settings/ | ||
| /*.vscode/ | ||
| /target/ | ||
|
|
||
| *.iml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Microsoft Open Source Code of Conduct | ||
|
|
||
| This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
|
|
||
| Resources: | ||
|
|
||
| - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) | ||
| - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) | ||
| - Contact [[email protected]](mailto:[email protected]) with questions or concerns |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) Microsoft Corporation. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| --- | ||
| page_type: sample | ||
| languages: | ||
| - java | ||
| products: | ||
| - java sdk | ||
| description: "Sample code repo for Azure Cosmos DB Java SDK for SQL API" | ||
| urlFragment: "" | ||
| --- | ||
|
|
||
| # Azure Cosmos DB Java SQL API Samples | ||
|
|
||
| <!-- | ||
| Guidelines on README format: https://review.docs.microsoft.com/help/onboard/admin/samples/concepts/readme-template?branch=master | ||
|
|
||
| Guidance on onboarding samples to docs.microsoft.com/samples: https://review.docs.microsoft.com/help/onboard/admin/samples/process/onboarding?branch=master | ||
|
|
||
| Taxonomies for products and languages: https://review.docs.microsoft.com/new-hope/information-architecture/metadata/taxonomies?branch=master | ||
| --> | ||
|
|
||
| Sample code repo for Azure Cosmos DB Java SDK for SQL API. By cloning and running these samples, and then studying their implementations, you will have an example for sending various requests to Azure Cosmos DB from Java SDK via the SQL API. | ||
|
|
||
| ## Contents | ||
|
|
||
| | File/folder | Description | | ||
| |-------------------|--------------------------------------------| | ||
| | `src` | Java sample source code. Many samples have 'sync' and 'async' variants | | ||
| | `.gitignore` | Define what to ignore at commit time. | | ||
| | `CHANGELOG.md` | List of changes to the sample. | | ||
| | `CONTRIBUTING.md` | Guidelines for contributing to the sample. | | ||
| | `README.md` | This README file. | | ||
| | `LICENSE` | The license for the sample. | | ||
| | `pom.xml` | Maven Project Object Model File | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| * A Java IDE such as IntelliJ IDEA or VSCode | ||
| * Maven | ||
| * Java SE JRE 8 | ||
| * Setting up an Azure Cosmos DB account through the Azure Portal. The **Create a database account** section of [this guide](https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java) walks you through account creation. | ||
| * The hostname and master key for your Azure Cosmos DB account | ||
|
|
||
| ## Setup | ||
|
|
||
| Clone the sample to your PC. Using your Java IDE, open pom.xml as a Maven project. | ||
|
|
||
| ## Running the sample | ||
|
|
||
| *If you are using Intellij IDEA as your Java IDE:* Once you have opened the project, go to the **Run/Debug Configurations** drop-down and choose **Edit Configurations**. | ||
| In the **Edit Configurations** dialog, click the **+** (**Add New Configuration**) button, select **Application** as the configuration type, | ||
| and give the new configuration a name. Once you are looking at the settings for your new Configuration, find **Environment variables** and paste | ||
|
|
||
| ``` | ||
| ACCOUNT_HOST=your account hostname;ACCOUNT_KEY=your account master key | ||
| ``` | ||
|
|
||
| which gives the sample read/write access to your account. | ||
|
|
||
| To choose which sample will run, populate the **Main class** field of the Configuration with | ||
|
|
||
| ``` | ||
| com.azure.cosmos.examples.changefeed.sample | ||
|
||
| ``` | ||
|
|
||
| where *sample* can be | ||
| * SampleCRUDQuickstart | ||
| * SampleCRUDQuickstartAsync | ||
| * SampleIndexManagement | ||
| * SampleIndexManagementAsync | ||
| * SampleStoredProcedure | ||
| * SampleStoredProcedureAsync | ||
| * SampleChangeFeedProcessor | ||
|
|
||
| *Build and execute from command line without an IDE:* From top-level directory of repo: | ||
| ``` | ||
| mvn clean package | ||
| mvn exec:java -Dexec.mainClass="com.azure.cosmos.examples.changefeed.sample" -DACCOUNT_HOST=your account hostname -DACCOUNT_KEY=your account master key | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto, the sample has changefeed in the package name |
||
| ``` | ||
|
|
||
| where *sample*, *your account hostname*, and *your account master key* are to be filled in as above. This will rebuild and run the selected sample. | ||
|
|
||
| ## Key concepts | ||
|
|
||
| These samples cover a range of Azure Cosmos DB usage topics from more to less basic: | ||
| * Basic management of databases, containers and items | ||
| * Indexing, stored procedures | ||
| * Change Feed | ||
|
|
||
| ## Contributing | ||
|
|
||
| This project welcomes contributions and suggestions. Most contributions require you to agree to a | ||
| Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us | ||
| the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. | ||
|
|
||
| When you submit a pull request, a CLA bot will automatically determine whether you need to provide | ||
| a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions | ||
| provided by the bot. You will only need to do this once across all repos using our CLA. | ||
|
|
||
| This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
| For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
| contact [[email protected]](mailto:[email protected]) with any additional questions or comments. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <!-- BEGIN MICROSOFT SECURITY.MD V0.0.3 BLOCK --> | ||
|
|
||
| ## Security | ||
|
|
||
| Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). | ||
|
|
||
| If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below. | ||
|
|
||
| ## Reporting Security Issues | ||
|
|
||
| **Please do not report security vulnerabilities through public GitHub issues.** | ||
|
|
||
| Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). | ||
|
|
||
| If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). | ||
|
|
||
| You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). | ||
|
|
||
| Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: | ||
|
|
||
| * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) | ||
| * Full paths of source file(s) related to the manifestation of the issue | ||
| * The location of the affected source code (tag/branch/commit or direct URL) | ||
| * Any special configuration required to reproduce the issue | ||
| * Step-by-step instructions to reproduce the issue | ||
| * Proof-of-concept or exploit code (if possible) | ||
| * Impact of the issue, including how an attacker might exploit the issue | ||
|
|
||
| This information will help us triage your report more quickly. | ||
|
|
||
| If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. | ||
|
|
||
| ## Preferred Languages | ||
|
|
||
| We prefer all communications to be in English. | ||
|
|
||
| ## Policy | ||
|
|
||
| Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). | ||
|
|
||
| <!-- END MICROSOFT SECURITY.MD BLOCK --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.azure</groupId> | ||
| <artifactId>azure-cosmos-java-sql-api-samples</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| <name>Get Started With Sync / Async Java SDK for SQL API of Azure Cosmos DB Database Service</name> | ||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
| <distributionManagement> | ||
| <repository> | ||
| <id>azure-sdk-for-java</id> | ||
| <url>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-java/maven/v1</url> | ||
| </repository> | ||
| </distributionManagement> | ||
| <repositories> | ||
| <repository> | ||
| <id>azure-sdk-for-java</id> | ||
| <url>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-java/maven/v1</url> | ||
| <releases> | ||
| <enabled>true</enabled> | ||
| </releases> | ||
| <snapshots> | ||
| <enabled>true</enabled> | ||
| </snapshots> | ||
| </repository> | ||
anfeldma-ms marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </repositories> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.1</version> | ||
| <configuration> | ||
| <source>1.8</source> | ||
| <target>1.8</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>exec-maven-plugin</artifactId> | ||
| <version>1.6.0</version> | ||
| <executions> | ||
| <execution> | ||
| <id>sync</id> | ||
| <configuration> | ||
| <mainClass>com.azure.cosmos.sample.sync.SyncMain</mainClass> | ||
| </configuration> | ||
| </execution> | ||
| <execution> | ||
| <id>async</id> | ||
| <configuration> | ||
| <mainClass>com.azure.cosmos.sample.async.AsyncMain</mainClass> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-eclipse-plugin</artifactId> | ||
| <version>2.8</version> | ||
| <configuration> | ||
| <classpathContainers> | ||
| <classpathContainer> | ||
| org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8 | ||
| </classpathContainer> | ||
| </classpathContainers> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.azure</groupId> | ||
| <artifactId>azure-cosmos</artifactId> | ||
| <version>4.0.1-beta.1</version> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
Uh oh!
There was an error while loading. Please reload this page.