Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Initial version

  • Loading branch information...
pablo cibraro
pablo cibraro committed Aug 17, 2016
1 parent 11c3b2b commit 53a45db54a3d662aacd43ced58a4d3983d3c2d80
Showing with 3,369 additions and 9 deletions.
  1. +62 −9 README.md
  2. +28 −0 storage-blob-cpp-getting-started.sln
  3. +60 −0 storage-blob-cpp-getting-started/CMakeLists.txt
  4. BIN storage-blob-cpp-getting-started/HelloWorld.png
  5. +710 −0 storage-blob-cpp-getting-started/blob_advanced.cpp
  6. +39 −0 storage-blob-cpp-getting-started/blob_advanced.h
  7. +230 −0 storage-blob-cpp-getting-started/blob_basic.cpp
  8. +31 −0 storage-blob-cpp-getting-started/blob_basic.h
  9. +48 −0 storage-blob-cpp-getting-started/cmake/Modules/FindAzureStorage.cmake
  10. +47 −0 storage-blob-cpp-getting-started/cmake/Modules/FindCasablanca.cmake
  11. +37 −0 storage-blob-cpp-getting-started/cmake/Modules/FindGlib.cmake
  12. +54 −0 storage-blob-cpp-getting-started/cmake/Modules/FindGlibmm.cmake
  13. +58 −0 storage-blob-cpp-getting-started/cmake/Modules/FindLibXML++.cmake
  14. +44 −0 storage-blob-cpp-getting-started/cmake/Modules/FindLibXML2.cmake
  15. +35 −0 storage-blob-cpp-getting-started/cmake/Modules/FindSigC++.cmake
  16. +108 −0 storage-blob-cpp-getting-started/cmake/Modules/FindUUID.cmake
  17. +34 −0 storage-blob-cpp-getting-started/cmake/Modules/FindUnitTest++.cmake
  18. +266 −0 storage-blob-cpp-getting-started/cmake/Modules/LibFindMacros.cmake
  19. +8 −0 storage-blob-cpp-getting-started/packages.config
  20. +302 −0 storage-blob-cpp-getting-started/queue_advanced.cpp
  21. +32 −0 storage-blob-cpp-getting-started/queue_advanced.h
  22. +203 −0 storage-blob-cpp-getting-started/queue_basic.cpp
  23. +28 −0 storage-blob-cpp-getting-started/queue_basic.h
  24. +23 −0 storage-blob-cpp-getting-started/stdafx.cpp
  25. +37 −0 storage-blob-cpp-getting-started/stdafx.h
  26. +184 −0 storage-blob-cpp-getting-started/storage-blob-cpp-getting-started.vcxproj
  27. +106 −0 storage-blob-cpp-getting-started/storage-getting-started.cpp
  28. +32 −0 storage-blob-cpp-getting-started/string_util.cpp
  29. +23 −0 storage-blob-cpp-getting-started/string_util.h
  30. +219 −0 storage-blob-cpp-getting-started/table_advanced.cpp
  31. +30 −0 storage-blob-cpp-getting-started/table_advanced.h
  32. +223 −0 storage-blob-cpp-getting-started/table_basic.cpp
  33. +28 −0 storage-blob-cpp-getting-started/table_basic.h
@@ -1,10 +1,63 @@
# storage-blob-cpp-getting-started
The getting started sample demonstrates how to perform common tasks using the Azure Blob Service in C++ including uploading a blob, CRUD operations, listing, as well as blob snapshot creation.
## Running this sample
Coming soon...
## Deploy this sample to Azure
Coming soon...
## About the code
Coming soon...
---
services: storage
platforms: cpp
author: pcibraro
---

# Azure Storage Service Samples in C++

Demonstrates how to use the Blob Service.

- Azure Blob storage is a service that stores unstructured data in the cloud as objects/blobs. Blob storage can store any type of text or binary data, such as documents, media files or application installers. Blob storage is also refered to as object storage. This sample demostrates how to perform common tasks for managing containers and blobs with data.

Note: This sample uses the Windows Azure Storage client library for C++ available through a Nuget package, which depends on the Visual Studio version you will use for development. For Visual Studio 2015, use the Nuget package "wastorage.v140". For Visual Studio 2013, use "wastorage.v120".

If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212).

## Running this sample in Windows

This sample can be run using either the Azure Storage Emulator that installs as part of the Windows Azure SDK - or by updating the storage_connection_string variable defined at the top of the program.

To run the sample using the Storage Emulator (Windows Azure SDK):

1. Download and Install the Azure Storage Emulator [here](http://azure.microsoft.com/en-us/downloads/).
2. Start the Azure Storage Emulator (once only) by pressing the Start button or the Windows key and searching for it by typing "Azure Storage Emulator". Select it from the list of applications to start it.
3. Set breakpoints and run the project using F10.

To run the sample using the Storage Service

1. Open the storage-getting-started.cpp file and find the variable storage_connection_string. Replace the value (UseDevelopmentStorage=True) with the connection string for the storage service (AccountName=[]...)
2. Create a Storage Account through the Azure Portal and provide your [AccountName] and [AccountKey] in the storage_connection_string variable.
3. Set breakpoints and run the project using F10.

## Running this sample in Linux

In order to compile and run this sample in Linux, you first need to get a local copy of the C++ REST SDK (aka Casablanca) from [here] (https://github.com/Microsoft/cpprestsdk) and the Azure Storage Client Library for C++ from [here] (https://github.com/Azure/azure-storage-cpp). Both libraries must be compiled following the instructions described in the corresponding Github repositories.
Once you have these libraries, follow these instructions to build the samples,

- Clone the project using git:
```bash
git clone https://github.com/Azure-Samples/storage-blob-cpp-getting-started.git
```
The project is cloned to a folder called `storage-blob-cpp-getting-started`. Always use the master branch, which contains the latest release.

- Build the samples:
```bash
cd storage-blob-cpp-getting-started/storage-blob-cpp-getting-started
mkdir build
cd build
CASABLANCA_DIR=<path to Casablanca> AZURESTORAGE_DIR=<path to AzureStorage> CXX=g++-4.8 cmake .. -DCMAKE_BUILD_TYPE=Release
make
```
In the above command, replace `<path to Casablanca>` to point to your local installation of Casablanca and `<path to Casablanca>` to point to your local installation of the Azure Storage Client library. For example, if the file `libcpprest.so` exists at location `~/Github/Casablanca/cpprestsdk/Release/build.release/Binaries/libcpprest.so` and the file `libazurestorage.so` exists at location `~/Github/azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release/Binaries/libazurestorage.so`, then your `cmake` command should be:
```bash
CASABLANCA_DIR=~/Github/Casablanca/cpprestsdk AZURESTORAGE_DIR=~/Github/azure-storage-cpp CXX=g++-4.8 cmake .. -DCMAKE_BUILD_TYPE=Release
```
The sample is generated under `storage-blob-cpp-getting-started/storage-blob-cpp-getting-started/build/Binaries/`.

## More information
Coming soon...
- [What is a Storage Account](http://azure.microsoft.com/en-us/documentation/articles/storage-whatis-account/)
- [How to use Blob Storage from C++](https://azure.microsoft.com/en-us/documentation/articles/storage-c-plus-plus-how-to-use-blobs/)
- [Blob Service Concepts](http://msdn.microsoft.com/en-us/library/dd179376.aspx)
- [Blob Service REST API](http://msdn.microsoft.com/en-us/library/dd135733.aspx)
- [Storage Emulator](http://msdn.microsoft.com/en-us/library/azure/hh403989.aspx)
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "storage-blob-cpp-getting-started", "storage-blob-cpp-getting-started\storage-blob-cpp-getting-started.vcxproj", "{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Debug|x64.ActiveCfg = Debug|x64
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Debug|x64.Build.0 = Debug|x64
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Debug|x86.ActiveCfg = Debug|Win32
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Debug|x86.Build.0 = Debug|Win32
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Release|x64.ActiveCfg = Release|x64
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Release|x64.Build.0 = Release|x64
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Release|x86.ActiveCfg = Release|Win32
{E7DA1623-2B9F-4B43-BE01-5FCD5F539C51}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,60 @@
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.6)
project(azurestoragesamples)

set(WARNINGS)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

# Platform (not compiler) specific settings
if(UNIX)
find_package(Boost REQUIRED COMPONENTS log log_setup random system thread locale regex filesystem chrono date_time)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Glibmm REQUIRED)
find_package(LibXML++ REQUIRED)
find_package(UUID REQUIRED)
find_package(Casablanca REQUIRED)
find_package(AzureStorage REQUIRED)
else()
message("-- Unsupported Build Platform.")
endif()

# Compiler (not platform) specific settings
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
message("-- Setting gcc options")

set(WARNINGS "-Wall -Wextra -Wunused-parameter -Wcast-align -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls -Wunreachable-code")
set(LINUX_SUPPRESSIONS "-Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-unused-function -Wno-char-subscripts -Wno-switch -Wno-unused-but-set-parameter -Wno-unused-value -Wno-unused-local-typedefs -Wno-unused-parameter")
set(WARNINGS "${WARNINGS} ${LINUX_SUPPRESSIONS}")

set(LD_FLAGS "${LD_FLAGS} -Wl,-z,defs")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing")

set(STRICT_CXX_FLAGS ${WARNINGS} "-Werror -pedantic")

add_definitions(-DBOOST_LOG_DYN_LINK)
else()
message("-- Unknown compiler, success is doubtful.")
endif()

# Reconfigure final output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)

set(AZURESTORAGESAMPLES_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${AZURESTORAGE_INCLUDE_DIR} ${CASABLANCA_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS} ${LibXML++_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} ${Glibmm_INCLUDE_DIRS})

set(AZURESTORAGESAMPLES_LIBRARIES ${AZURESTORAGE_LIBRARIES} ${CASABLANCA_LIBRARIES} ${Boost_LIBRARIES} ${Boost_FRAMEWORK} ${OPENSSL_LIBRARIES} ${LibXML++_LIBRARIES} ${UUID_LIBRARIES} ${Glibmm_LIBRARIES})

include_directories(. ${AZURESTORAGESAMPLES_INCLUDE_DIRS})

add_executable(azurestoragesamples storage-getting-started.cpp
stdafx.cpp
string_util.cpp
blob_basic.cpp
blob_advanced.cpp)
target_link_libraries(azurestoragesamples ${AZURESTORAGESAMPLES_LIBRARIES})

file(COPY HelloWorld.png DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
Binary file not shown.

0 comments on commit 53a45db

Please sign in to comment.
You can’t perform that action at this time.