This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql.{SaveMode, SparkSession} | |
object HelloCosmos { | |
val cosmosEndpoint = "" | |
val cosmosMasterKey = "" | |
val cosmosDatabaseName = "bstore" | |
val cosmosContainerName = "books" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
azure.cosmos.uri=https://some-cosmossql-demo.documents.azure.com:443/ | |
azure.cosmos.key=APEDwfem16N7K74Il5Y5SSSSOMby7KAIfrLnzKOV0JMMoaedg0IhHepvmLOi7HnG5mHIRCyqomSTj6oa3urlOg== | |
azure.cosmos.database=store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class CustomerLoader { | |
private CustomerRepository customerRepository; | |
@Autowired | |
CustomerLoader(CustomerRepository customerRepository){ | |
this.customerRepository=customerRepository; | |
} | |
@PostConstruct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public class CustomerController { | |
private CustomerRepository customerRepository; | |
@Autowired | |
CustomerController(CustomerRepository customerRepository) { | |
this.customerRepository = customerRepository; | |
} | |
@GetMapping("/customers") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
public interface CustomerRepository extends CosmosRepository<Customer,String> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Customer { | |
@Id | |
@PartitionKey | |
String id; | |
String firstName; | |
String lastName; | |
String emailAddress; | |
String zipcode; | |
public Customer(String id, String firstName, String lastName, String emailAddress, String zipcode) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "1", | |
"firstName": "Ravi", | |
"lastName": "Tella", | |
"emailAddress": "ravi@email.com", | |
"zipcode": "33333" | |
}, | |
{ | |
"id": "2", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Patch using a json string with JsonNode (JAckson) | |
private static void pathUpdate1() throws JsonProcessingException { | |
String json = "{\"City\":\"Atlanta\",\"State\": \"GA\",\"Country\":\"USA\"}"; | |
ObjectMapper objectMapper = new ObjectMapper(); | |
JsonNode jsonNode = objectMapper.readTree(json); | |
CosmosPatchOperations cosmosPatchOperations2 = CosmosPatchOperations.create(); | |
cosmosPatchOperations2.add("/address1", jsonNode); | |
CosmosPatchItemRequestOptions options2 = new CosmosPatchItemRequestOptions(); | |
cosmosDB.getContainer().patchItem("6", new PartitionKey("Databases"), | |
cosmosPatchOperations2, options2, Book.class).block(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import com.microsoft.azure.documentdb.*; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.stereotype.Service; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sendToPBI(rowAsJson: String ): Unit = { | |
val post = new HttpPost("") | |
post.addHeader(HttpHeaders.CONTENT_TYPE, "application/json") | |
post.setEntity(new StringEntity(rowAsJson)) | |
val response = (HttpClientBuilder.create().build()).execute(post) | |
} | |
import org.apache.spark.sql._ | |
castedTelemetryData |
NewerOlder