├── .gitattributes ├── .gitignore ├── BreakingChanges.txt ├── CONTRIBUTING.md ├── Changelog.txt ├── Doxyfile ├── LICENSE.txt ├── Microsoft.WindowsAzure.Storage.v140.sln ├── Microsoft.WindowsAzure.Storage.v141.sln ├── Microsoft.WindowsAzure.Storage ├── CMakeLists.txt ├── Microsoft.WindowsAzure.Storage.v140.vcxproj ├── Microsoft.WindowsAzure.Storage.v140.vcxproj.filters ├── Microsoft.WindowsAzure.Storage.v141.vcxproj ├── Microsoft.WindowsAzure.Storage.v141.vcxproj.filters ├── cmake │ └── Modules │ │ ├── FindCasablanca.cmake │ │ ├── FindGlib.cmake │ │ ├── FindLibXML2.cmake │ │ ├── FindSigC++.cmake │ │ ├── FindUUID.cmake │ │ ├── FindUnitTest++.cmake │ │ └── LibFindMacros.cmake ├── includes │ ├── stdafx.h │ ├── targetver.h │ ├── was │ │ ├── auth.h │ │ ├── blob.h │ │ ├── common.h │ │ ├── core.h │ │ ├── crc64.h │ │ ├── error_code_strings.h │ │ ├── file.h │ │ ├── queue.h │ │ ├── retry_policies.h │ │ ├── service_client.h │ │ ├── storage_account.h │ │ └── table.h │ └── wascore │ │ ├── async_semaphore.h │ │ ├── basic_types.h │ │ ├── blobstreams.h │ │ ├── constants.dat │ │ ├── constants.h │ │ ├── executor.h │ │ ├── filestream.h │ │ ├── hashing.h │ │ ├── logging.h │ │ ├── protocol.h │ │ ├── protocol_json.h │ │ ├── protocol_xml.h │ │ ├── resources.h │ │ ├── streambuf.h │ │ ├── streams.h │ │ ├── timer_handler.h │ │ ├── util.h │ │ ├── xml_wrapper.h │ │ ├── xmlhelpers.h │ │ └── xmlstream.h ├── resource.h ├── samples │ ├── BlobsGettingStarted.cpp │ ├── BlobsPerformanceBenchmark.cpp │ ├── CMakeLists.txt │ ├── FilesGettingStarted.cpp │ ├── FilesProperties.cpp │ ├── JsonPayloadFormat.cpp │ ├── Microsoft.WindowsAzure.Storage.Samples.v140.vcxproj │ ├── Microsoft.WindowsAzure.Storage.Samples.v140.vcxproj.filters │ ├── Microsoft.WindowsAzure.Storage.Samples.v141.vcxproj │ ├── Microsoft.WindowsAzure.Storage.Samples.v141.vcxproj.filters │ ├── NativeClientLibraryDemo1.cpp │ ├── NativeClientLibraryDemo2.cpp │ ├── OAuthGettingStarted.cpp │ ├── QueuesGettingStarted.cpp │ ├── TablesGettingStarted.cpp │ ├── main.cpp │ └── samples_common.h ├── src │ ├── CMakeLists.txt │ ├── async_semaphore.cpp │ ├── authentication.cpp │ ├── basic_types.cpp │ ├── blob_request_factory.cpp │ ├── blob_response_parsers.cpp │ ├── cloud_append_blob.cpp │ ├── cloud_blob.cpp │ ├── cloud_blob_client.cpp │ ├── cloud_blob_container.cpp │ ├── cloud_blob_directory.cpp │ ├── cloud_blob_istreambuf.cpp │ ├── cloud_blob_ostreambuf.cpp │ ├── cloud_blob_shared.cpp │ ├── cloud_block_blob.cpp │ ├── cloud_client.cpp │ ├── cloud_common.cpp │ ├── cloud_core.cpp │ ├── cloud_file.cpp │ ├── cloud_file_client.cpp │ ├── cloud_file_directory.cpp │ ├── cloud_file_ostreambuf.cpp │ ├── cloud_file_share.cpp │ ├── cloud_page_blob.cpp │ ├── cloud_queue.cpp │ ├── cloud_queue_client.cpp │ ├── cloud_queue_message.cpp │ ├── cloud_storage_account.cpp │ ├── cloud_table.cpp │ ├── cloud_table_client.cpp │ ├── constants.cpp │ ├── crc64.cpp │ ├── entity_property.cpp │ ├── executor.cpp │ ├── file_request_factory.cpp │ ├── file_response_parsers.cpp │ ├── hashing.cpp │ ├── logging.cpp │ ├── mime_multipart_helper.cpp │ ├── navigation.cpp │ ├── operation_context.cpp │ ├── protocol_json.cpp │ ├── protocol_xml.cpp │ ├── queue_request_factory.cpp │ ├── request_factory.cpp │ ├── request_result.cpp │ ├── resources.cpp │ ├── response_parsers.cpp │ ├── retry_policies.cpp │ ├── shared_access_signature.cpp │ ├── stdafx.cpp │ ├── streams.cpp │ ├── table_query.cpp │ ├── table_request_factory.cpp │ ├── table_response_parsers.cpp │ ├── timer_handler.cpp │ ├── util.cpp │ ├── xml_wrapper.cpp │ └── xmlhelpers.cpp ├── tests │ ├── CMakeLists.txt │ ├── Microsoft.WindowsAzure.Storage.UnitTests.v140.vcxproj │ ├── Microsoft.WindowsAzure.Storage.UnitTests.v140.vcxproj.filters │ ├── Microsoft.WindowsAzure.Storage.UnitTests.v141.vcxproj │ ├── Microsoft.WindowsAzure.Storage.UnitTests.v141.vcxproj.filters │ ├── README.md │ ├── blob_lease_test.cpp │ ├── blob_streams_test.cpp │ ├── blob_test_base.cpp │ ├── blob_test_base.h │ ├── blob_versioning_test.cpp │ ├── check_macros.h │ ├── checksum_test.cpp │ ├── cloud_append_blob_test.cpp │ ├── cloud_blob_client_test.cpp │ ├── cloud_blob_container_test.cpp │ ├── cloud_blob_directory_test.cpp │ ├── cloud_blob_test.cpp │ ├── cloud_block_blob_test.cpp │ ├── cloud_file_client_test.cpp │ ├── cloud_file_directory_test.cpp │ ├── cloud_file_share_test.cpp │ ├── cloud_file_test.cpp │ ├── cloud_page_blob_test.cpp │ ├── cloud_queue_client_test.cpp │ ├── cloud_queue_test.cpp │ ├── cloud_storage_account_test.cpp │ ├── cloud_table_client_test.cpp │ ├── cloud_table_test.cpp │ ├── executor_test.cpp │ ├── file_test_base.cpp │ ├── file_test_base.h │ ├── main.cpp │ ├── queue_test_base.cpp │ ├── queue_test_base.h │ ├── read_from_secondary_test.cpp │ ├── result_iterator_test.cpp │ ├── retry_policy_test.cpp │ ├── service_properties_test.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ ├── storage_exception_test.cpp │ ├── table_test_base.cpp │ ├── table_test_base.h │ ├── targetver.h │ ├── test_base.cpp │ ├── test_base.h │ ├── test_configurations.json │ ├── timer_handler_test.cpp │ └── unicode_test.cpp └── version.rc ├── README.md ├── SECURITY.md ├── azure-pipelines.yml ├── build.proj ├── build.sln └── documentation └── Microsoft Azure Storage Client Library for C++ 2.0.0.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | 65 | # Allow diff of UTF-16 text files. 66 | *.rc diff 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # MSTest test Results 20 | [Tt]est[Rr]esult*/ 21 | [Bb]uild[Ll]og.* 22 | 23 | #NUNIT 24 | *.VisualState.xml 25 | TestResult.xml 26 | 27 | *_i.c 28 | *_p.c 29 | *_i.h 30 | *.ilk 31 | *.meta 32 | *.obj 33 | *.pch 34 | *.pdb 35 | *.pgc 36 | *.pgd 37 | *.rsp 38 | *.sbr 39 | *.tlb 40 | *.tli 41 | *.tlh 42 | *.tmp 43 | *.tmp_proj 44 | *.log 45 | *.vspscc 46 | *.vssscc 47 | .builds 48 | *.pidb 49 | *.svclog 50 | *.scc 51 | 52 | # Chutzpah Test files 53 | _Chutzpah* 54 | 55 | # Visual C++ cache files 56 | ipch/ 57 | *.aps 58 | *.ncb 59 | *.opensdf 60 | *.sdf 61 | *.cachefile 62 | 63 | # Visual Studio profiler 64 | *.psess 65 | *.vsp 66 | *.vspx 67 | 68 | # TFS 2012 Local Workspace 69 | $tf/ 70 | 71 | # Guidance Automation Toolkit 72 | *.gpState 73 | 74 | # ReSharper is a .NET coding add-in 75 | _ReSharper*/ 76 | *.[Rr]e[Ss]harper 77 | *.DotSettings.user 78 | 79 | # JustCode is a .NET coding addin-in 80 | .JustCode 81 | 82 | # TeamCity is a build add-in 83 | _TeamCity* 84 | 85 | # DotCover is a Code Coverage Tool 86 | *.dotCover 87 | 88 | # NCrunch 89 | *.ncrunch* 90 | _NCrunch_* 91 | .*crunch*.local.xml 92 | 93 | # MightyMoose 94 | *.mm.* 95 | AutoTest.Net/ 96 | 97 | # Installshield output folder 98 | [Ee]xpress/ 99 | 100 | # DocProject is a documentation generator add-in 101 | DocProject/buildhelp/ 102 | DocProject/Help/*.HxT 103 | DocProject/Help/*.HxC 104 | DocProject/Help/*.hhc 105 | DocProject/Help/*.hhk 106 | DocProject/Help/*.hhp 107 | DocProject/Help/Html2 108 | DocProject/Help/html 109 | 110 | # Click-Once directory 111 | publish/ 112 | 113 | # Publish Web Output 114 | *.Publish.xml 115 | *.azurePubxml 116 | 117 | # NuGet Packages Directory 118 | packages/ 119 | !packages/repositories.config 120 | 121 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 122 | #!packages/*/build/ 123 | 124 | # Windows Azure Build Output 125 | csx/ 126 | *.build.csdef 127 | 128 | # Windows Store app package directory 129 | AppPackages/ 130 | 131 | # Others 132 | sql/ 133 | *.Cache 134 | ClientBin/ 135 | [Ss]tyle[Cc]op.* 136 | ~$* 137 | *~ 138 | *.dbmdl 139 | *.dbproj.schemaview 140 | *.[Pp]ublish.xml 141 | *.pfx 142 | *.publishsettings 143 | 144 | # RIA/Silverlight projects 145 | Generated_Code/ 146 | 147 | # Backup & report files from converting an old project file to a newer 148 | # Visual Studio version. Backup files are not needed, because we have git ;-) 149 | _UpgradeReport_Files/ 150 | Backup*/ 151 | UpgradeLog*.XML 152 | UpgradeLog*.htm 153 | 154 | # SQL Server files 155 | App_Data/*.mdf 156 | App_Data/*.ldf 157 | 158 | # Business Intelligence projects 159 | *.rdl.data 160 | *.bim.layout 161 | *.bim_*.settings 162 | 163 | # Microsoft Fakes 164 | FakesAssemblies/ 165 | 166 | # Nuget packages 167 | *.nupkg 168 | 169 | # ========================= 170 | # Windows detritus 171 | # ========================= 172 | 173 | # Windows image file caches 174 | Thumbs.db 175 | ehthumbs.db 176 | 177 | # Folder config file 178 | Desktop.ini 179 | 180 | # Recycle Bin used on file shares 181 | $RECYCLE.BIN/ 182 | 183 | # build folders under Linux 184 | Microsoft.WindowsAzure.Storage/build.*/ 185 | 186 | # ========================== 187 | # OSX detritus 188 | # ========================== 189 | 190 | .DS_Store 191 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage.v140.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.WindowsAzure.Storage.v140", "Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.v140.vcxproj", "{25D342C3-6CDA-44DD-A16A-32A19B692785}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|Win32.Build.0 = Debug|Win32 18 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x64.ActiveCfg = Debug|x64 19 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x64.Build.0 = Debug|x64 20 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|Win32.ActiveCfg = Release|Win32 21 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|Win32.Build.0 = Release|Win32 22 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x64.ActiveCfg = Release|x64 23 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage.v141.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.421 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.WindowsAzure.Storage.v141", "Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.v141.vcxproj", "{25D342C3-6CDA-44DD-A16A-32A19B692785}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x64.ActiveCfg = Debug|x64 17 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x64.Build.0 = Debug|x64 18 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x86.ActiveCfg = Debug|Win32 19 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x86.Build.0 = Debug|Win32 20 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x64.ActiveCfg = Release|x64 21 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x64.Build.0 = Release|x64 22 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x86.ActiveCfg = Release|Win32 23 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {EFC9951D-9CFA-4AF9-8EA2-0DE2E2A03DF5} 30 | SolutionGuid = {657A09C9-C87D-40F4-B9C2-A41DE55BB7A2} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/cmake/Modules/FindCasablanca.cmake: -------------------------------------------------------------------------------- 1 | # FindCasablanca package 2 | # 3 | # Tries to find the Casablanca (C++ REST SDK) library 4 | # 5 | 6 | find_package(PkgConfig) 7 | 8 | include(LibFindMacros) 9 | 10 | if(WIN32) 11 | find_package(cpprestsdk) 12 | 13 | if(cpprestsdk_FOUND) 14 | set(CASABLANCA_LIBRARY cpprestsdk::cpprest) 15 | set(CASABLANCA_PROCESS_LIBS CASABLANCA_LIBRARY) 16 | set(CASABLANCA_PROCESS_INCLUDES CASABLANCA_INCLUDE_DIR) 17 | libfind_process(CASABLANCA) 18 | return() 19 | endif() 20 | else() 21 | # Include dir 22 | find_path(CASABLANCA_INCLUDE_DIR 23 | NAMES 24 | cpprest/http_client.h 25 | PATHS 26 | ${CASABLANCA_PKGCONF_INCLUDE_DIRS} 27 | ${CASABLANCA_DIR} 28 | $ENV{CASABLANCA_DIR} 29 | /usr/local/include 30 | /usr/include 31 | ../../casablanca 32 | PATH_SUFFIXES 33 | Release/include 34 | include 35 | ) 36 | endif() 37 | 38 | # Library 39 | find_library(CASABLANCA_LIBRARY 40 | NAMES 41 | cpprest 42 | cpprest_2_9.lib 43 | PATHS 44 | ${CASABLANCA_PKGCONF_LIBRARY_DIRS} 45 | ${CASABLANCA_DIR} 46 | ${CASABLANCA_DIR} 47 | $ENV{CASABLANCA_DIR} 48 | /usr/local 49 | /usr 50 | ../../casablanca 51 | PATH_SUFFIXES 52 | lib 53 | Release/build.release/Binaries/ 54 | build.release/Binaries/ 55 | ) 56 | 57 | set(CASABLANCA_PROCESS_LIBS CASABLANCA_LIBRARY) 58 | set(CASABLANCA_PROCESS_INCLUDES CASABLANCA_INCLUDE_DIR) 59 | libfind_process(CASABLANCA) 60 | 61 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/cmake/Modules/FindGlib.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Glib-2.0 (with gobject) 2 | # Once done, this will define 3 | # 4 | # Glib_FOUND - system has Glib 5 | # Glib_INCLUDE_DIRS - the Glib include directories 6 | # Glib_LIBRARIES - link these to use Glib 7 | 8 | include(LibFindMacros) 9 | 10 | # Use pkg-config to get hints about paths 11 | libfind_pkg_check_modules(Glib_PKGCONF glib-2.0) 12 | 13 | # Main include dir 14 | find_path(Glib_INCLUDE_DIR 15 | NAMES glib.h 16 | PATHS ${Glib_PKGCONF_INCLUDE_DIRS} 17 | PATH_SUFFIXES glib-2.0 18 | ) 19 | 20 | # Glib-related libraries also use a separate config header, which is in lib dir 21 | find_path(GlibConfig_INCLUDE_DIR 22 | NAMES glibconfig.h 23 | PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr 24 | PATH_SUFFIXES lib/glib-2.0/include 25 | ) 26 | 27 | # Finally the library itself 28 | find_library(Glib_LIBRARY 29 | NAMES glib-2.0 30 | PATHS ${Glib_PKGCONF_LIBRARY_DIRS} 31 | ) 32 | 33 | # Set the include dir variables and the libraries and let libfind_process do the rest. 34 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 35 | set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR) 36 | set(Glib_PROCESS_LIBS Glib_LIBRARY) 37 | libfind_process(Glib) 38 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/cmake/Modules/FindLibXML2.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find LibXML2 headers and libraries. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(LibXML2) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # LibXML2_ROOT_DIR Set this variable to the root installation of 11 | # LibXML2 if the module has problems finding 12 | # the proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # LIBXML2_FOUND System has LibXML2 libs/headers 17 | # LibXML2_LIBRARY The LibXML2 libraries 18 | # LibXML2_INCLUDE_DIR The location of LibXML2 headers 19 | 20 | include(LibFindMacros) 21 | 22 | # Use pkg-config to get hints about paths 23 | libfind_pkg_check_modules(LibXML2_PKGCONF libxml2) 24 | 25 | find_path(LibXML2_ROOT_DIR 26 | NAMES include/libxml2/libxml/tree.h 27 | ) 28 | 29 | find_library(LibXML2_LIBRARY 30 | NAMES xml2 31 | HINTS ${LibXML2_ROOT_DIR}/lib 32 | ) 33 | 34 | find_path(LibXML2_INCLUDE_DIR 35 | NAMES libxml/tree.h 36 | HINTS ${LibXML2_ROOT_DIR}/include/libxml2 37 | ) 38 | 39 | set(LibXML2_PROCESS_LIBS LibXML2_LIBRARY) 40 | set(LibXML2_PROCESS_INCLUDES LibXML2_INCLUDE_DIR) 41 | 42 | libfind_process(LibXML2) 43 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/cmake/Modules/FindSigC++.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find SigC++-2.0 2 | # Once done, this will define 3 | # 4 | # SigC++_FOUND - system has SigC++ 5 | # SigC++_INCLUDE_DIRS - the SigC++ include directories 6 | # SigC++_LIBRARIES - link these to use SigC++ 7 | 8 | include(LibFindMacros) 9 | 10 | # Use pkg-config to get hints about paths 11 | libfind_pkg_check_modules(SigC++_PKGCONF sigc++-2.0) 12 | 13 | # Main include dir 14 | find_path(SigC++_INCLUDE_DIR 15 | NAMES sigc++/sigc++.h 16 | PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} 17 | PATH_SUFFIXES sigc++-2.0 18 | ) 19 | 20 | # Glib-related libraries also use a separate config header, which is in lib dir 21 | find_path(SigC++Config_INCLUDE_DIR 22 | NAMES sigc++config.h 23 | PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} 24 | ) 25 | 26 | # find_library(SigC++_LIBRARY 27 | # NAMES SigC SigC-2.0 28 | # PATHS ${SigC++_PKGCONF_LIBRARY_DIRS} 29 | # ) 30 | 31 | # Set the include dir variables and the libraries and let libfind_process do the rest. 32 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 33 | set(SigC++_PROCESS_INCLUDES SigC++_INCLUDE_DIR SigC++Config_INCLUDE_DIR) 34 | set(SigC++_PROCESS_LIBS SigC++_LIBRARY) 35 | libfind_process(SigC++) 36 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/cmake/Modules/FindUUID.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find UUID 2 | # Once done this will define 3 | # 4 | # UUID_FOUND - system has UUID 5 | # UUID_INCLUDE_DIRS - the UUID include directory 6 | # UUID_LIBRARIES - Link these to use UUID 7 | # UUID_DEFINITIONS - Compiler switches required for using UUID 8 | # 9 | # Copyright (c) 2006 Andreas Schneider 10 | # 11 | # Redistribution and use is allowed according to the terms of the New 12 | # BSD license. 13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 14 | # 15 | 16 | 17 | if (UUID_LIBRARIES AND UUID_INCLUDE_DIRS) 18 | # in cache already 19 | set(UUID_FOUND TRUE) 20 | else (UUID_LIBRARIES AND UUID_INCLUDE_DIRS) 21 | find_path(UUID_INCLUDE_DIR 22 | NAMES 23 | uuid/uuid.h 24 | PATHS 25 | ${UUID_DIR}/include 26 | $ENV{UUID_DIR}/include 27 | $ENV{UUID_DIR} 28 | ${DELTA3D_EXT_DIR}/inc 29 | $ENV{DELTA_ROOT}/ext/inc 30 | $ENV{DELTA_ROOT} 31 | ~/Library/Frameworks 32 | /Library/Frameworks 33 | /usr/local/include 34 | /usr/include 35 | /usr/include/gdal 36 | /sw/include # Fink 37 | /opt/local/include # DarwinPorts 38 | /opt/csw/include # Blastwave 39 | /opt/include 40 | [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include 41 | /usr/freeware/include 42 | ) 43 | 44 | find_library(UUID_LIBRARY 45 | NAMES 46 | uuid 47 | PATHS 48 | ${UUID_DIR}/lib 49 | $ENV{UUID_DIR}/lib 50 | $ENV{UUID_DIR} 51 | ${DELTA3D_EXT_DIR}/lib 52 | $ENV{DELTA_ROOT}/ext/lib 53 | $ENV{DELTA_ROOT} 54 | $ENV{OSG_ROOT}/lib 55 | ~/Library/Frameworks 56 | /Library/Frameworks 57 | /usr/local/lib 58 | /usr/lib 59 | /sw/lib 60 | /opt/local/lib 61 | /opt/csw/lib 62 | /opt/lib 63 | /usr/freeware/lib64 64 | ) 65 | 66 | if (APPLE) 67 | if (NOT UUID_LIBRARY) 68 | set(UUID_LIBRARY "") 69 | endif (NOT UUID_LIBRARY) 70 | endif (APPLE) 71 | 72 | find_library(UUID_LIBRARY_DEBUG 73 | NAMES 74 | uuidd 75 | PATHS 76 | ${UUID_DIR}/lib 77 | $ENV{UUID_DIR}/lib 78 | $ENV{UUID_DIR} 79 | ${DELTA3D_EXT_DIR}/lib 80 | $ENV{DELTA_ROOT}/ext/lib 81 | $ENV{DELTA_ROOT} 82 | $ENV{OSG_ROOT}/lib 83 | ~/Library/Frameworks 84 | /Library/Frameworks 85 | /usr/local/lib 86 | /usr/lib 87 | /sw/lib 88 | /opt/local/lib 89 | /opt/csw/lib 90 | /opt/lib 91 | /usr/freeware/lib64 92 | ) 93 | 94 | set(UUID_INCLUDE_DIRS ${UUID_INCLUDE_DIR}) 95 | set(UUID_LIBRARIES ${UUID_LIBRARY}) 96 | 97 | if (UUID_INCLUDE_DIRS AND (APPLE OR UUID_LIBRARIES)) 98 | set(UUID_FOUND TRUE) 99 | endif (UUID_INCLUDE_DIRS AND (APPLE OR UUID_LIBRARIES)) 100 | 101 | if (UUID_FOUND) 102 | if (NOT UUID_FIND_QUIETLY) 103 | message(STATUS "Found UUID : ${UUID_LIBRARIES}") 104 | endif (NOT UUID_FIND_QUIETLY) 105 | else (UUID_FOUND) 106 | if (UUID_FIND_REQUIRED) 107 | message(FATAL_ERROR "Could not find UUID") 108 | endif (UUID_FIND_REQUIRED) 109 | endif (UUID_FOUND) 110 | 111 | # show the UUID_INCLUDE_DIRS and UUID_LIBRARIES variables only in the advanced view 112 | mark_as_advanced(UUID_INCLUDE_DIRS UUID_LIBRARIES) 113 | 114 | endif (UUID_LIBRARIES AND UUID_INCLUDE_DIRS) 115 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/cmake/Modules/FindUnitTest++.cmake: -------------------------------------------------------------------------------- 1 | # find UnitTest++ 2 | # 3 | # exports: 4 | # 5 | # UnitTest++_FOUND 6 | # UnitTest++_INCLUDE_DIRS 7 | # UnitTest++_LIBRARIES 8 | # 9 | 10 | include(FindPkgConfig) 11 | include(FindPackageHandleStandardArgs) 12 | 13 | # Use pkg-config to get hints about paths 14 | pkg_check_modules(UnitTest++_PKGCONF QUIET unittest++) 15 | 16 | # Include dir 17 | find_path(UnitTest++_INCLUDE_DIR 18 | NAMES UnitTest++.h 19 | PATHS 20 | ${UnitTest++_PKGCONF_INCLUDE_DIRS} 21 | ${CMAKE_SOURCE_DIR}/tests/UnitTest++/src 22 | /usr/local/include 23 | /usr/include 24 | PATH_SUFFIXES 25 | unittest++ 26 | UnitTest++ 27 | ) 28 | 29 | # Library 30 | find_library(UnitTest++_LIBRARY 31 | NAMES unittest++ UnitTest++ 32 | PATHS 33 | ${UnitTest++_PKGCONF_LIBRARY_DIRS} 34 | ${CMAKE_SOURCE_DIR}/tests/UnitTest++ 35 | /usr/local/lib 36 | ) 37 | 38 | set(UnitTest++_PROCESS_LIBS UnitTest++_LIBRARY) 39 | set(UnitTest++_PROCESS_INCLUDES UnitTest++_INCLUDE_DIR) 40 | libfind_process(UnitTest++) 41 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/stdafx.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | // stdafx.h : include file for standard system include files, 19 | // or project specific include files that are used frequently, but 20 | // are changed infrequently 21 | // 22 | 23 | #pragma once 24 | 25 | #include "targetver.h" 26 | 27 | #pragma warning(push) 28 | #pragma warning(disable: 4634 4635 4638 4251 4100 4503 4996) 29 | 30 | #ifndef NOMINMAX 31 | #define NOMINMAX 32 | #endif 33 | 34 | // This is required to support enough number of arguments in VC11, especially for std::bind 35 | #define _VARIADIC_MAX 8 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "cpprest/http_client.h" 49 | #include "cpprest/filestream.h" 50 | #include "cpprest/producerconsumerstream.h" 51 | 52 | #pragma warning(pop) 53 | 54 | #pragma warning(disable: 4503) -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/targetver.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | // Including SDKDDKVer.h defines the highest available Windows platform. 21 | 22 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 23 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 24 | 25 | #ifdef _WIN32 26 | #include 27 | #endif 28 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/was/crc64.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2019 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "wascore/basic_types.h" 21 | 22 | 23 | namespace azure { namespace storage { 24 | 25 | constexpr uint64_t INITIAL_CRC64 = 0ULL; 26 | 27 | WASTORAGE_API uint64_t update_crc64(const uint8_t* data, size_t size, uint64_t crc); 28 | WASTORAGE_API void set_crc64_func(std::function func); 29 | 30 | inline uint64_t crc64(const uint8_t* data, size_t size) 31 | { 32 | return update_crc64(data, size, INITIAL_CRC64); 33 | } 34 | 35 | }} // namespace azure::storage -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/async_semaphore.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include "cpprest/asyncrt_utils.h" 24 | 25 | #include "wascore/basic_types.h" 26 | 27 | namespace azure { namespace storage { namespace core { 28 | 29 | class _async_semaphore 30 | { 31 | public: 32 | 33 | explicit _async_semaphore(int count) 34 | : m_count(count), m_initial_count(count) 35 | { 36 | m_empty_event.set(); 37 | } 38 | 39 | pplx::task lock_async(); 40 | void unlock(); 41 | pplx::task wait_all_async(); 42 | 43 | private: 44 | 45 | pplx::task_completion_event dequeue_pending(); 46 | 47 | int m_count; 48 | int m_initial_count; 49 | pplx::task_completion_event m_empty_event; 50 | std::queue> m_queue; 51 | pplx::extensibility::reader_writer_lock_t m_mutex; 52 | }; 53 | 54 | class async_semaphore 55 | { 56 | public: 57 | 58 | explicit async_semaphore(int count) 59 | : m_semaphore(std::make_shared<_async_semaphore>(count)) 60 | { 61 | } 62 | 63 | pplx::task lock_async() 64 | { 65 | return m_semaphore->lock_async(); 66 | } 67 | 68 | void lock() 69 | { 70 | lock_async().wait(); 71 | } 72 | 73 | void unlock() 74 | { 75 | return m_semaphore->unlock(); 76 | } 77 | 78 | pplx::task wait_all_async() 79 | { 80 | return m_semaphore->wait_all_async(); 81 | } 82 | 83 | private: 84 | 85 | std::shared_ptr<_async_semaphore> m_semaphore; 86 | }; 87 | 88 | }}} // namespace azure::storage::core 89 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/basic_types.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | #pragma warning(disable: 4634) 20 | 21 | #include "cpprest/details/basic_types.h" 22 | 23 | #ifdef _NO_WASTORAGE_API 24 | #define WASTORAGE_API 25 | #else 26 | #ifdef WASTORAGE_DLL 27 | #define WASTORAGE_API __declspec( dllexport ) 28 | #else 29 | #define WASTORAGE_API __declspec( dllimport ) 30 | #endif 31 | #endif 32 | 33 | #ifdef _WIN32 34 | #define DEPRECATED(message) __declspec(deprecated(message)) 35 | #else 36 | #define DEPRECATED(message) __attribute__((deprecated(message))) 37 | #endif 38 | 39 | #ifdef _WIN32 40 | 41 | #ifndef WIN32_LEAN_AND_MEAN 42 | #define WIN32_LEAN_AND_MEAN 43 | #endif 44 | #ifndef NOMINMAX 45 | #define NOMINMAX 46 | #endif 47 | 48 | #include 49 | #else 50 | extern "C" 51 | { 52 | #include 53 | } 54 | #endif 55 | 56 | namespace utility { 57 | 58 | //typedef struct { uint8_t data[16]; } uuid; 59 | 60 | #ifdef _WIN32 61 | typedef UUID uuid; 62 | #else 63 | typedef struct 64 | { 65 | uuid_t data; 66 | } uuid; 67 | #endif 68 | 69 | /// 70 | /// Generates a new UUID. 71 | /// 72 | WASTORAGE_API utility::uuid __cdecl new_uuid(); 73 | 74 | /// 75 | /// Converts an UUID to a string. 76 | /// 77 | WASTORAGE_API utility::string_t __cdecl uuid_to_string(const utility::uuid& value); 78 | 79 | /// 80 | /// Converts a string to a UUID. 81 | /// 82 | WASTORAGE_API utility::uuid __cdecl string_to_uuid(const utility::string_t& value); 83 | 84 | /// 85 | /// Compares two UUIDs for equality. 86 | /// 87 | WASTORAGE_API bool __cdecl uuid_equal(const utility::uuid& value1, const utility::uuid& value2); 88 | 89 | template 90 | void assert_in_bounds(const utility::string_t& param_name, const T& value, const T& min) 91 | { 92 | if (value < min) 93 | { 94 | throw std::invalid_argument(utility::conversions::to_utf8string(param_name)); 95 | } 96 | } 97 | 98 | template 99 | void assert_in_bounds(const utility::string_t& param_name, const T& value, const T& min, const T& max) 100 | { 101 | assert_in_bounds(param_name, value, min); 102 | 103 | if (value > max) 104 | { 105 | throw std::invalid_argument(utility::conversions::to_utf8string(param_name)); 106 | } 107 | } 108 | 109 | } // namespace utility 110 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/constants.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "cpprest/asyncrt_utils.h" 21 | 22 | #include "wascore/basic_types.h" 23 | 24 | namespace azure { namespace storage { namespace protocol { 25 | 26 | // size constants 27 | const size_t max_block_number = 50000; 28 | const utility::size64_t max_block_size = 4 * 1000 * 1024 * 1024ULL; 29 | const utility::size64_t max_block_blob_size = static_cast(max_block_number) * max_block_size; 30 | const size_t max_append_block_size = 4 * 1024 * 1024; 31 | const size_t max_page_size = 4 * 1024 * 1024; 32 | const size_t max_range_size = 4 * 1024 * 1024; 33 | const utility::size64_t max_single_blob_upload_threshold = 5000 * 1024 * 1024ULL; 34 | 35 | const size_t default_stream_write_size = 4 * 1024 * 1024; 36 | const size_t default_stream_read_size = 4 * 1024 * 1024; 37 | const size_t default_buffer_size = 64 * 1024; 38 | const bool default_validate_certificates = true; 39 | const utility::size64_t default_single_blob_upload_threshold = 128 * 1024 * 1024; 40 | const utility::size64_t default_single_blob_download_threshold = 32 * 1024 * 1024; 41 | const utility::size64_t default_single_block_download_threshold = 4 * 1024 * 1024; 42 | const size_t transactional_md5_block_size = 4 * 1024 * 1024; 43 | 44 | // duration constants 45 | const std::chrono::seconds default_retry_interval(3); 46 | // The following value must be less than 2147482, which is the highest 47 | // that Casablanca 2.2.0 on Linux can accept, which is derived from 48 | // the maximum value for a signed long on g++, divided by 1000. 49 | // Choosing to set it to 24 days to align with .NET. 50 | const std::chrono::milliseconds default_maximum_execution_time(24 * 24 * 60 * 60 * 1000); 51 | // the following value is used to exit the network connection if there is no activity in network. 52 | const std::chrono::seconds default_noactivity_timeout(60); 53 | // For the following value, "0" means "don't send a timeout to the service" 54 | const std::chrono::seconds default_server_timeout(0); 55 | 56 | // lease break period and duration constants 57 | const std::chrono::seconds minimum_lease_break_period(0); 58 | const std::chrono::seconds maximum_lease_break_period(60); 59 | const std::chrono::seconds minimum_fixed_lease_duration(15); 60 | const std::chrono::seconds maximum_fixed_lease_duration(60); 61 | 62 | #define _CONSTANTS 63 | #define DAT(a, b) WASTORAGE_API extern const utility::char_t a[]; const size_t a ## _size = sizeof(b) / sizeof(utility::char_t) - 1; 64 | #include "constants.dat" 65 | #undef DAT 66 | #undef _CONSTANTS 67 | 68 | }}} // namespace azure::storage::protocol 69 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/filestream.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "basic_types.h" 21 | #include "streams.h" 22 | #include "async_semaphore.h" 23 | #include "util.h" 24 | #include "was/file.h" 25 | 26 | namespace azure { namespace storage { namespace core { 27 | 28 | class basic_cloud_file_ostreambuf : public basic_cloud_ostreambuf 29 | { 30 | public: 31 | basic_cloud_file_ostreambuf(std::shared_ptr file, utility::size64_t length, const file_access_condition& access_condition, const file_request_options& options, operation_context context) 32 | : m_file(file), m_file_length(length), m_condition(access_condition), m_options(options), m_context(context), 33 | m_semaphore(options.parallelism_factor()),m_current_file_offset(0) 34 | { 35 | m_buffer_size = protocol::max_range_size; 36 | m_next_buffer_size = protocol::max_range_size; 37 | 38 | if (m_options.use_transactional_md5()) 39 | { 40 | m_transaction_hash_provider = hash_provider::create_md5_hash_provider(); 41 | } 42 | if (m_options.store_file_content_md5()) 43 | { 44 | m_total_hash_provider = hash_provider::create_md5_hash_provider(); 45 | } 46 | } 47 | 48 | bool can_seek() const 49 | { 50 | return can_write() && !m_options.store_file_content_md5(); 51 | } 52 | 53 | bool has_size() const 54 | { 55 | return true; 56 | } 57 | 58 | utility::size64_t size() const 59 | { 60 | return m_file_length; 61 | } 62 | 63 | pos_type seekpos(pos_type pos, std::ios_base::openmode direction) 64 | { 65 | if (can_seek() && (direction == std::ios_base::out)) 66 | { 67 | if ((pos < (pos_type)0) || (pos >(pos_type)size())) 68 | { 69 | return (pos_type)traits::eof(); 70 | } 71 | 72 | sync().wait(); 73 | m_current_file_offset = pos; 74 | m_current_streambuf_offset = pos; 75 | return (pos_type)m_current_streambuf_offset; 76 | } 77 | else 78 | { 79 | return (pos_type)traits::eof(); 80 | } 81 | } 82 | 83 | pplx::task _sync(); 84 | 85 | protected: 86 | 87 | pplx::task upload_buffer(); 88 | pplx::task commit_close(); 89 | 90 | std::shared_ptr m_file; 91 | utility::size64_t m_file_length; 92 | file_access_condition m_condition; 93 | file_request_options m_options; 94 | operation_context m_context; 95 | int64_t m_current_file_offset; 96 | async_semaphore m_semaphore; 97 | 98 | }; 99 | 100 | class cloud_file_ostreambuf : public concurrency::streams::streambuf 101 | { 102 | public: 103 | cloud_file_ostreambuf(std::shared_ptr file, utility::size64_t length, const file_access_condition& access_condition, const file_request_options& options, operation_context context) 104 | : concurrency::streams::streambuf(std::make_shared(file, length, access_condition, options, context)) 105 | { 106 | } 107 | 108 | }; 109 | 110 | 111 | }}} // azure::storage::core -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/logging.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "wascore/basic_types.h" 21 | #include "was/common.h" 22 | 23 | namespace azure { namespace storage { namespace core { 24 | 25 | class logger 26 | { 27 | public: 28 | 29 | static const logger& instance() 30 | { 31 | return m_instance; 32 | } 33 | 34 | ~logger(); 35 | 36 | void log(azure::storage::operation_context context, client_log_level level, const std::string& message) const; 37 | 38 | #ifdef _WIN32 39 | void log(azure::storage::operation_context context, client_log_level level, const std::wstring& message) const; 40 | #endif 41 | bool should_log(azure::storage::operation_context context, client_log_level level) const; 42 | 43 | private: 44 | 45 | logger(); 46 | 47 | static logger m_instance; 48 | }; 49 | 50 | }}} // namespace azure::storage::core 51 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/protocol_json.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "wascore/basic_types.h" 21 | #include "was/table.h" 22 | 23 | namespace azure { namespace storage { namespace protocol { 24 | 25 | table_entity parse_table_entity(const web::json::value& document); 26 | storage_extended_error parse_table_error(const web::json::value& document); 27 | utility::string_t parse_file_permission(const web::json::value& document); 28 | utility::string_t construct_file_permission(const utility::string_t& value); 29 | 30 | }}} // namespace azure::storage::protocol 31 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/resources.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "cpprest/asyncrt_utils.h" 21 | 22 | #include "wascore/basic_types.h" 23 | 24 | namespace azure { namespace storage { namespace protocol { 25 | 26 | #define _RESOURCES 27 | #define DAT(a, b) extern const char* a; const size_t a ## _size = sizeof(b) / sizeof(char) - 1; 28 | #include "wascore/constants.dat" 29 | #undef DAT 30 | #undef _RESOURCES 31 | 32 | }}} // namespace azure::storage::protocol 33 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/includes/wascore/timer_handler.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2018 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "cpprest/http_client.h" 21 | #include 22 | 23 | #include "wascore/constants.h" 24 | 25 | #ifndef _WIN32 26 | #include 27 | #include 28 | #include "pplx/threadpool.h" 29 | #else 30 | #include 31 | #endif 32 | 33 | namespace azure { namespace storage { namespace core { 34 | /// 35 | /// Used for internal logic of timer handling, including timer creation, deletion and cancellation 36 | /// 37 | class timer_handler : public std::enable_shared_from_this 38 | { 39 | public: 40 | WASTORAGE_API explicit timer_handler(const pplx::cancellation_token& token); 41 | 42 | WASTORAGE_API ~timer_handler(); 43 | 44 | WASTORAGE_API void start_timer(const std::chrono::milliseconds& time); 45 | 46 | WASTORAGE_API void stop_timer(); 47 | 48 | bool timer_started() const 49 | { 50 | return m_timer_started.load(std::memory_order_acquire); 51 | } 52 | 53 | pplx::cancellation_token get_cancellation_token() const 54 | { 55 | return m_worker_cancellation_token_source.get_token(); 56 | } 57 | 58 | bool is_canceled() const 59 | { 60 | return m_worker_cancellation_token_source.get_token().is_canceled(); 61 | } 62 | 63 | bool is_canceled_by_timeout() const 64 | { 65 | return m_is_canceled_by_timeout.load(std::memory_order_acquire); 66 | } 67 | 68 | private: 69 | pplx::cancellation_token_source m_worker_cancellation_token_source; 70 | pplx::cancellation_token_registration m_cancellation_token_registration; 71 | pplx::cancellation_token m_cancellation_token; 72 | pplx::task m_timeout_task; 73 | std::atomic m_is_canceled_by_timeout; 74 | pplx::task_completion_event m_tce; 75 | 76 | std::mutex m_mutex; 77 | 78 | WASTORAGE_API pplx::task timeout_after(const std::chrono::milliseconds& time); 79 | 80 | #ifndef _WIN32 81 | std::shared_ptr> m_timer; 82 | #else 83 | std::shared_ptr> m_timer; 84 | #endif 85 | std::atomic m_timer_started; 86 | }; 87 | }}} 88 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by version.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/BlobsPerformanceBenchmark.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace azure { namespace storage { namespace samples { 31 | 32 | SAMPLE(BlobsPerformanceBenchmark, blobs_performance_benchmark) 33 | void blobs_performance_benchmark() 34 | { 35 | try 36 | { 37 | azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); 38 | 39 | azure::storage::cloud_blob_client blob_client = storage_account.create_cloud_blob_client(); 40 | azure::storage::cloud_blob_container container = blob_client.get_container_reference(_XPLATSTR("benchmark-container")); 41 | 42 | container.create_if_not_exists(); 43 | 44 | const uint64_t blob_size = 1024 * 1024 * 1024; 45 | const int parallelism = 20; 46 | 47 | std::vector buffer; 48 | buffer.resize(blob_size); 49 | 50 | std::mt19937_64 rand_engine(std::random_device{}()); 51 | std::uniform_int_distribution dist; 52 | std::generate(reinterpret_cast(buffer.data()), reinterpret_cast(buffer.data() + buffer.size()), [&dist, &rand_engine]() { return dist(rand_engine); }); 53 | 54 | azure::storage::blob_request_options options; 55 | options.set_parallelism_factor(8); 56 | options.set_use_transactional_crc64(false); 57 | options.set_use_transactional_md5(false); 58 | options.set_store_blob_content_md5(false); 59 | options.set_stream_write_size_in_bytes(32 * 1024 * 1024); 60 | 61 | std::vector> tasks; 62 | 63 | auto start = std::chrono::steady_clock::now(); 64 | for (int i = 0; i < parallelism; ++i) 65 | { 66 | auto blob = container.get_block_blob_reference(_XPLATSTR("blob") + utility::conversions::to_string_t(std::to_string(i))); 67 | auto task = blob.upload_from_stream_async(concurrency::streams::container_buffer>(buffer).create_istream(), blob_size, azure::storage::access_condition(), options, azure::storage::operation_context()); 68 | tasks.emplace_back(std::move(task)); 69 | } 70 | for (auto& t : tasks) 71 | { 72 | t.get(); 73 | } 74 | auto end = std::chrono::steady_clock::now(); 75 | 76 | double elapsed_s = double(std::chrono::duration_cast(end - start).count()) / 1000; 77 | uint64_t data_mb = blob_size * parallelism / 1024 / 1024; 78 | 79 | std::cout << "Uploaded " << data_mb << "MB in " << elapsed_s << " seconds, throughput " << data_mb / elapsed_s << "MBps" << std::endl; 80 | 81 | tasks.clear(); 82 | start = std::chrono::steady_clock::now(); 83 | { 84 | std::vector>> download_buffers; 85 | for (int i = 0; i < parallelism; ++i) 86 | { 87 | auto blob = container.get_block_blob_reference(_XPLATSTR("blob") + utility::conversions::to_string_t(std::to_string(i))); 88 | download_buffers.emplace_back(concurrency::streams::container_buffer>()); 89 | auto task = blob.download_to_stream_async(download_buffers.back().create_ostream(), azure::storage::access_condition(), options, azure::storage::operation_context()); 90 | tasks.emplace_back(std::move(task)); 91 | } 92 | for (auto& t : tasks) 93 | { 94 | t.get(); 95 | } 96 | end = std::chrono::steady_clock::now(); 97 | } 98 | 99 | elapsed_s = double(std::chrono::duration_cast(end - start).count()) / 1000; 100 | 101 | std::cout << "Downloaded " << data_mb << "MB in " << elapsed_s << " seconds, throughput " << data_mb / elapsed_s << "MBps" << std::endl; 102 | } 103 | catch (const azure::storage::storage_exception& e) 104 | { 105 | std::cout << e.what() << std::endl; 106 | } 107 | } 108 | 109 | }}} // namespace azure::storage::samples 110 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(UNIX) 2 | set(SOURCES 3 | BlobsGettingStarted.cpp 4 | BlobsPerformanceBenchmark.cpp 5 | FilesGettingStarted.cpp 6 | JsonPayloadFormat.cpp 7 | main.cpp 8 | NativeClientLibraryDemo1.cpp 9 | NativeClientLibraryDemo2.cpp 10 | OAuthGettingStarted.cpp 11 | QueuesGettingStarted.cpp 12 | samples_common.h 13 | TablesGettingStarted.cpp 14 | FilesProperties.cpp 15 | ) 16 | endif() 17 | 18 | add_executable(${AZUREAZURAGE_LIBRARY_SAMPLE} ${SOURCES}) 19 | 20 | target_include_directories(${AZUREAZURAGE_LIBRARY_SAMPLE} PRIVATE ${AZURESTORAGE_INCLUDE_DIRS}) 21 | target_link_libraries(${AZUREAZURAGE_LIBRARY_SAMPLE} ${AZURESTORAGE_LIBRARIES}) 22 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/FilesGettingStarted.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | namespace azure { namespace storage { namespace samples { 26 | 27 | SAMPLE(FilesGettingStarted, files_getting_started_sample) 28 | void files_getting_started_sample() 29 | { 30 | try 31 | { 32 | // Initialize storage account 33 | azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); 34 | 35 | // Create share, directory 36 | azure::storage::cloud_file_client file_client = storage_account.create_cloud_file_client(); 37 | azure::storage::cloud_file_share share = file_client.get_share_reference(_XPLATSTR("my-sample-share")); 38 | azure::storage::cloud_file_directory directory = share.get_directory_reference(_XPLATSTR("my-sample-directory")); 39 | 40 | // Return value is true if the share did not exist and was successfully created. 41 | share.create_if_not_exists(); 42 | 43 | // Return value is true if the directory did not exist and was successfully created. 44 | directory.create_if_not_exists(); 45 | 46 | // Create a sub-directory. 47 | azure::storage::cloud_file_directory subdirectory = directory.get_subdirectory_reference(_XPLATSTR("my-sample-subdirectory")); 48 | subdirectory.create_if_not_exists(); 49 | 50 | // Upload a file from a stream. 51 | concurrency::streams::istream input_stream = concurrency::streams::file_stream::open_istream(_XPLATSTR("DataFile.txt")).get(); 52 | azure::storage::cloud_file file1 = directory.get_file_reference(_XPLATSTR("my-sample-file-1")); 53 | file1.upload_from_stream(input_stream); 54 | 55 | // Upload some files from text. 56 | azure::storage::cloud_file file2 = directory.get_file_reference(_XPLATSTR("my-sample-file-2")); 57 | file2.upload_text(_XPLATSTR("more text")); 58 | azure::storage::cloud_file file3 = directory.get_file_reference(_XPLATSTR("my-sample-file-3")); 59 | file3.upload_text(_XPLATSTR("other text")); 60 | 61 | // Upload a file from a file. 62 | azure::storage::cloud_file file4 = directory.get_file_reference(_XPLATSTR("my-sample-file-4")); 63 | file4.upload_from_file(_XPLATSTR("DataFile.txt")); 64 | 65 | // List files and directories in the directory 66 | azure::storage::continuation_token token; 67 | do 68 | { 69 | azure::storage::list_file_and_directory_result_segment result = directory.list_files_and_directories_segmented(token); 70 | for (auto& item : result.results()) 71 | { 72 | if (item.is_file()) 73 | { 74 | ucout << "File: " << item.as_file().uri().primary_uri().to_string() << std::endl; 75 | } 76 | if (item.is_directory()) 77 | { 78 | ucout << "Directory: " << item.as_directory().uri().primary_uri().to_string() << std::endl; 79 | } 80 | } 81 | } 82 | while (!token.empty()); 83 | 84 | // Download text file. 85 | azure::storage::cloud_file text_file = directory.get_file_reference(_XPLATSTR("my-sample-file-2")); 86 | utility::string_t text = text_file.download_text(); 87 | ucout << "File Text: " << text << std::endl; 88 | 89 | // Delete the files. 90 | file1.delete_file(); 91 | file2.delete_file(); 92 | file3.delete_file(); 93 | file4.delete_file(); 94 | 95 | // Delete the directories; 96 | subdirectory.delete_directory(); 97 | directory.delete_directory(); 98 | 99 | // Delete the file share. 100 | share.delete_share_if_exists(); 101 | } 102 | catch (const azure::storage::storage_exception& e) 103 | { 104 | ucout << _XPLATSTR("Error: ") << e.what() << std::endl; 105 | 106 | azure::storage::request_result result = e.result(); 107 | azure::storage::storage_extended_error extended_error = result.extended_error(); 108 | if (!extended_error.message().empty()) 109 | { 110 | ucout << extended_error.message() << std::endl; 111 | } 112 | } 113 | catch (const std::exception& e) 114 | { 115 | ucout << _XPLATSTR("Error: ") << e.what() << std::endl; 116 | } 117 | } 118 | 119 | }}} // namespace azure::storage::samples -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/FilesProperties.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | 23 | 24 | namespace azure { namespace storage { namespace samples { 25 | 26 | SAMPLE(FilesProperties, files_properties_sample) 27 | void files_properties_sample() 28 | { 29 | try 30 | { 31 | // Initialize storage account 32 | azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); 33 | 34 | // Create share 35 | azure::storage::cloud_file_client file_client = storage_account.create_cloud_file_client(); 36 | azure::storage::cloud_file_share share = file_client.get_share_reference(_XPLATSTR("my-sample-share")); 37 | share.create_if_not_exists(); 38 | 39 | // azure-storage-cpp sdk treats permission as an opaque string. The string below is pretty much a default permission. 40 | utility::string_t permission = _XPLATSTR("O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-2127521184-1604012920-1887927527-513D:(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)"); 41 | utility::string_t permission_key = share.upload_file_permission(permission); 42 | 43 | azure::storage::cloud_file_directory directory = share.get_directory_reference(_XPLATSTR("my-sample-directory")); 44 | directory.delete_directory_if_exists(); 45 | 46 | // Create a new directory with properties. 47 | directory.properties().set_attributes(azure::storage::cloud_file_attributes::directory | azure::storage::cloud_file_attributes::system); 48 | directory.properties().set_creation_time(azure::storage::cloud_file_directory_properties::now); 49 | directory.properties().set_last_write_time(utility::datetime::from_string(_XPLATSTR("Thu, 31 Oct 2019 06:42:18 GMT"))); 50 | // You can specify either permission or permission key, but not both. 51 | directory.properties().set_permission(permission); 52 | //directory.properties().set_permission_key(permission_key); 53 | directory.create(); 54 | 55 | // Upload a file. 56 | azure::storage::cloud_file file = directory.get_file_reference(_XPLATSTR("my-sample-file-1")); 57 | // Properties for file are pretty much the same as for directory. 58 | // You can leave properties unset to use default. 59 | file.properties().set_attributes(azure::storage::cloud_file_attributes::archive); 60 | //file.properties().set_permission(azure::storage::cloud_file_properties::inherit); 61 | file.properties().set_permission_key(permission_key); 62 | file.upload_text(_XPLATSTR("some text")); 63 | 64 | // Update properties for an existing file/directory. 65 | file.properties().set_creation_time(utility::datetime::from_string(_XPLATSTR("Wed, 10 Oct 2001 20:51:31 +0000"))); 66 | file.upload_properties(); 67 | 68 | file.delete_file(); 69 | directory.delete_directory(); 70 | share.delete_share_if_exists(); 71 | } 72 | catch (const azure::storage::storage_exception& e) 73 | { 74 | ucout << _XPLATSTR("Error: ") << e.what() << std::endl; 75 | 76 | azure::storage::request_result result = e.result(); 77 | azure::storage::storage_extended_error extended_error = result.extended_error(); 78 | if (!extended_error.message().empty()) 79 | { 80 | ucout << extended_error.message() << std::endl; 81 | } 82 | } 83 | catch (const std::exception& e) 84 | { 85 | ucout << _XPLATSTR("Error: ") << e.what() << std::endl; 86 | } 87 | } 88 | 89 | }}} // namespace azure::storage::samples 90 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/Microsoft.WindowsAzure.Storage.Samples.v140.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/Microsoft.WindowsAzure.Storage.Samples.v141.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/NativeClientLibraryDemo1.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2019 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | namespace azure { namespace storage { namespace samples { 26 | 27 | SAMPLE(Channel9GoingNativeDemo1, channel9_going_native_demo1) 28 | void channel9_going_native_demo1() { 29 | try 30 | { 31 | azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); 32 | 33 | azure::storage::cloud_table_client table_client = storage_account.create_cloud_table_client(); 34 | azure::storage::cloud_table table = table_client.get_table_reference(_XPLATSTR("blogposts")); 35 | table.create_if_not_exists(); 36 | 37 | azure::storage::cloud_queue_client queue_client = storage_account.create_cloud_queue_client(); 38 | azure::storage::cloud_queue queue = queue_client.get_queue_reference(_XPLATSTR("blog-processing")); 39 | queue.create_if_not_exists(); 40 | 41 | while (true) 42 | { 43 | utility::string_t name; 44 | ucin >> name; 45 | 46 | 47 | // Table 48 | 49 | azure::storage::table_batch_operation batch_operation; 50 | for (int i = 0; i < 3; ++i) 51 | { 52 | utility::string_t partition_key = _XPLATSTR("partition"); 53 | utility::string_t row_key = name + utility::conversions::to_string_t(std::to_string(i)); 54 | 55 | azure::storage::table_entity entity(partition_key, row_key); 56 | entity.properties()[_XPLATSTR("PostId")] = azure::storage::entity_property(rand()); 57 | entity.properties()[_XPLATSTR("Content")] = azure::storage::entity_property(utility::string_t(_XPLATSTR("some text"))); 58 | entity.properties()[_XPLATSTR("Date")] = azure::storage::entity_property(utility::datetime::utc_now()); 59 | batch_operation.insert_entity(entity); 60 | } 61 | 62 | pplx::task table_task = table.execute_batch_async(batch_operation).then([](std::vector results) 63 | { 64 | for (auto it = results.cbegin(); it != results.cend(); ++it) 65 | { 66 | ucout << _XPLATSTR("Status: ") << it->http_status_code() << std::endl; 67 | } 68 | }); 69 | 70 | 71 | // Queue 72 | 73 | azure::storage::cloud_queue_message queue_message(name); 74 | std::chrono::seconds time_to_live(100000); 75 | std::chrono::seconds initial_visibility_timeout(rand() % 30); 76 | azure::storage::queue_request_options options; 77 | 78 | pplx::task queue_task = queue.add_message_async(queue_message, time_to_live, initial_visibility_timeout, options, azure::storage::operation_context()); 79 | 80 | 81 | queue_task.wait(); 82 | table_task.wait(); 83 | } 84 | } 85 | catch (const azure::storage::storage_exception& e) 86 | { 87 | ucout << e.what() << std::endl; 88 | } 89 | } 90 | }}} // namespace azure::storage::samples 91 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/NativeClientLibraryDemo2.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2019 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | namespace azure { namespace storage { namespace samples { 29 | 30 | SAMPLE(Channel9GoingNativeDemo2, channel9_going_native_demo2) 31 | void channel9_going_native_demo2() { 32 | try 33 | { 34 | azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); 35 | 36 | azure::storage::cloud_table_client table_client = storage_account.create_cloud_table_client(); 37 | azure::storage::cloud_table table = table_client.get_table_reference(_XPLATSTR("blogposts")); 38 | table.create_if_not_exists(); 39 | 40 | azure::storage::cloud_queue_client queue_client = storage_account.create_cloud_queue_client(); 41 | azure::storage::cloud_queue queue = queue_client.get_queue_reference(_XPLATSTR("blog-processing")); 42 | queue.create_if_not_exists(); 43 | 44 | while (true) 45 | { 46 | azure::storage::cloud_queue_message message = queue.get_message(); 47 | if (!message.id().empty()) 48 | { 49 | utility::string_t partition_key(_XPLATSTR("partition")); 50 | utility::string_t start_row_key = message.content_as_string(); 51 | utility::string_t end_row_key = message.content_as_string() + _XPLATSTR(":"); 52 | 53 | azure::storage::table_query query; 54 | query.set_filter_string(azure::storage::table_query::combine_filter_conditions( 55 | azure::storage::table_query::combine_filter_conditions( 56 | azure::storage::table_query::generate_filter_condition(_XPLATSTR("PartitionKey"), azure::storage::query_comparison_operator::equal, partition_key), 57 | azure::storage::query_logical_operator::op_and, 58 | azure::storage::table_query::generate_filter_condition(_XPLATSTR("RowKey"), azure::storage::query_comparison_operator::greater_than, start_row_key)), 59 | azure::storage::query_logical_operator::op_and, 60 | azure::storage::table_query::generate_filter_condition(_XPLATSTR("RowKey"), azure::storage::query_comparison_operator::less_than, end_row_key)) 61 | ); 62 | 63 | azure::storage::table_query_iterator it = table.execute_query(query); 64 | azure::storage::table_query_iterator end_of_results; 65 | for (; it != end_of_results; ++it) 66 | { 67 | ucout << _XPLATSTR("Entity: ") << it->row_key() << _XPLATSTR(" "); 68 | ucout << it->properties().at(_XPLATSTR("PostId")).int32_value() << _XPLATSTR(" "); 69 | ucout << it->properties().at(_XPLATSTR("Content")).string_value() << std::endl; 70 | } 71 | 72 | queue.delete_message(message); 73 | } 74 | 75 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 76 | } 77 | 78 | table.delete_table_if_exists(); 79 | queue.delete_queue_if_exists(); 80 | } 81 | catch (const azure::storage::storage_exception& e) 82 | { 83 | ucout << e.what() << std::endl; 84 | } 85 | } 86 | }}} // namespace azure::storage::samples 87 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/OAuthGettingStarted.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2019 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | 23 | 24 | namespace azure { namespace storage { namespace samples { 25 | 26 | SAMPLE(OAuthGettingStarted, oauth_getting_started_sample) 27 | void oauth_getting_started_sample() 28 | { 29 | utility::string_t account_name = _XPLATSTR("YOUR ACCOUNT_NAME"); 30 | utility::string_t oauth_access_token(_XPLATSTR("PUT_YOUR_OAUTH_2_0_ACCESS_TOKEN_HERE")); 31 | 32 | using OAuthAccessToken = azure::storage::storage_credentials::bearer_token_credential; 33 | azure::storage::storage_credentials storage_cred(account_name, OAuthAccessToken{ oauth_access_token }); 34 | 35 | azure::storage::cloud_storage_account storage_account(storage_cred, /* use https */ true); 36 | 37 | auto blob_client = storage_account.create_cloud_blob_client(); 38 | auto blob_container = blob_client.get_container_reference(_XPLATSTR("YOUR_CONTAINER")); 39 | auto blob = blob_container.get_blob_reference(_XPLATSTR("FOO.BAR")); 40 | 41 | try 42 | { 43 | std::cout << blob.exists() << std::endl; 44 | } 45 | catch (const azure::storage::storage_exception& e) 46 | { 47 | std::cout << e.what() << std::endl; 48 | } 49 | 50 | // Here we make some copies of the storage credential. 51 | azure::storage::storage_credentials storage_cred2(storage_cred); 52 | azure::storage::storage_credentials storage_cred3; 53 | storage_cred3 = storage_cred2; 54 | azure::storage::storage_credentials storage_cred4(OAuthAccessToken{ oauth_access_token }); 55 | 56 | // After a while, the access token may expire, refresh it. 57 | storage_cred.set_bearer_token(_XPLATSTR("YOUR_NEW_OAUTH_2_0_ACCESS_TOKEN")); 58 | // storage_cred2.set_bearer_token(_XPLATSTR("YOUR_NEW_OAUTH_2_0_ACCESS_TOKEN")); 59 | // storage_cred3.set_bearer_token(_XPLATSTR("YOUR_NEW_OAUTH_2_0_ACCESS_TOKEN")); 60 | // Note that, every storage_crentials struct copied directly or indirectly shares the same underlaying access token. 61 | // So the three lines above have the same effect. 62 | 63 | // But if you create another storage_crendials with the same access token, they are not interconnected because they are not created by coping or assigning. 64 | storage_cred4.set_bearer_token(_XPLATSTR("YOUR_NEW_OAUTH_2_0_ACCESS_TOKEN")); // This doesn't change access token inside storage_cred{1,2,3} 65 | 66 | try 67 | { 68 | std::cout << blob.exists() << std::endl; 69 | } 70 | catch (const azure::storage::storage_exception& e) 71 | { 72 | std::cout << e.what() << std::endl; 73 | } 74 | } 75 | }}} // namespace azure::storage::samples -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/QueuesGettingStarted.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | #include 21 | #include 22 | 23 | 24 | namespace azure { namespace storage { namespace samples { 25 | 26 | SAMPLE(QueuesGettingStarted, queues_getting_started_sample) 27 | void queues_getting_started_sample() 28 | { 29 | try 30 | { 31 | // Initialize storage account 32 | azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); 33 | 34 | // Create a queue 35 | azure::storage::cloud_queue_client queue_client = storage_account.create_cloud_queue_client(); 36 | azure::storage::cloud_queue queue = queue_client.get_queue_reference(_XPLATSTR("my-sample-queue")); 37 | 38 | // Return value is true if the queue did not exist and was successfully created. 39 | queue.create_if_not_exists(); 40 | 41 | // Insert some queue messages 42 | azure::storage::cloud_queue_message message1(_XPLATSTR("some message")); 43 | queue.add_message(message1); 44 | azure::storage::cloud_queue_message message2(_XPLATSTR("different message")); 45 | queue.add_message(message2); 46 | azure::storage::cloud_queue_message message3(_XPLATSTR("another message")); 47 | queue.add_message(message3); 48 | 49 | // Peek the next queue message 50 | azure::storage::cloud_queue_message peeked_message = queue.peek_message(); 51 | ucout << _XPLATSTR("Peek: ") << peeked_message.content_as_string() << std::endl; 52 | 53 | // Dequeue the next queue message 54 | azure::storage::cloud_queue_message dequeued_message = queue.get_message(); 55 | ucout << _XPLATSTR("Get: ") << dequeued_message.content_as_string() << std::endl; 56 | 57 | // Update a queue message (content and visibility timeout) 58 | dequeued_message.set_content(_XPLATSTR("changed message")); 59 | queue.update_message(dequeued_message, std::chrono::seconds(30), true); 60 | ucout << _XPLATSTR("Update: ") << dequeued_message.content_as_string() << std::endl; 61 | 62 | // Delete the queue message 63 | queue.delete_message(dequeued_message); 64 | 65 | // Dequeue some queue messages (maximum 32 at a time) and set their visibility timeout to 5 minutes 66 | azure::storage::queue_request_options options; 67 | azure::storage::operation_context context; 68 | std::vector messages = queue.get_messages(32, std::chrono::seconds(300), options, context); 69 | for (std::vector::const_iterator it = messages.cbegin(); it != messages.cend(); ++it) 70 | { 71 | ucout << _XPLATSTR("Get: ") << it->content_as_string() << std::endl; 72 | } 73 | 74 | // Delete the queue messages 75 | for (std::vector::iterator it = messages.begin(); it != messages.end(); ++it) 76 | { 77 | queue.delete_message(*it); 78 | } 79 | 80 | // Get the approximate queue size 81 | queue.download_attributes(); 82 | ucout << _XPLATSTR("Approximate message count: ") << queue.approximate_message_count() << std::endl; 83 | 84 | // Delete the queue 85 | // Return value is true if the queue did exist and was succesfully deleted. 86 | queue.delete_queue_if_exists(); 87 | } 88 | catch (const azure::storage::storage_exception& e) 89 | { 90 | ucout << _XPLATSTR("Error: ") << e.what() << std::endl; 91 | 92 | azure::storage::request_result result = e.result(); 93 | azure::storage::storage_extended_error extended_error = result.extended_error(); 94 | if (!extended_error.message().empty()) 95 | { 96 | ucout << extended_error.message() << std::endl; 97 | } 98 | } 99 | catch (const std::exception& e) 100 | { 101 | ucout << _XPLATSTR("Error: ") << e.what() << std::endl; 102 | } 103 | } 104 | 105 | }}} // namespace azure::storage::samples -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/main.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2019 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "samples_common.h" 19 | 20 | 21 | int main(int argc, char** argv) 22 | { 23 | if (argc != 2) 24 | { 25 | printf("Usage: %s \n", argv[0]); 26 | } 27 | else 28 | { 29 | auto ite = Sample::samples().find(argv[1]); 30 | if (ite == Sample::samples().end()) 31 | { 32 | printf("Cannot find sample %s\n", argv[1]); 33 | } 34 | else 35 | { 36 | auto func = ite->second; 37 | func(); 38 | return 0; 39 | } 40 | } 41 | 42 | printf("\nAvailable sample names:\n"); 43 | for (const auto& i : Sample::samples()) 44 | { 45 | printf(" %s\n", i.first.data()); 46 | } 47 | return 1; 48 | } -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/samples/samples_common.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "was/common.h" 21 | 22 | 23 | namespace azure { namespace storage { namespace samples { 24 | 25 | // TODO: Put your account name and account key here 26 | const utility::string_t storage_connection_string(_XPLATSTR("DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myaccountkey")); 27 | 28 | }}} // namespace azure::storage::samples 29 | 30 | 31 | class Sample 32 | { 33 | public: 34 | static const std::map>& samples() 35 | { 36 | return m_samples(); 37 | } 38 | 39 | protected: 40 | static void add_sample(std::string sample_name, std::function func) 41 | { 42 | m_samples().emplace(std::move(sample_name), std::move(func)); 43 | } 44 | 45 | private: 46 | static std::map>& m_samples() 47 | { 48 | static std::map> samples_instance; 49 | return samples_instance; 50 | } 51 | }; 52 | 53 | #define SAMPLE(NAME, FUNCTION) \ 54 | void FUNCTION(); \ 55 | \ 56 | class Sample ## NAME : public Sample \ 57 | { \ 58 | public: \ 59 | Sample ## NAME() \ 60 | { \ 61 | add_sample(#NAME, FUNCTION); \ 62 | } \ 63 | }; \ 64 | namespace { \ 65 | Sample ## NAME Sample ## NAME_; \ 66 | } 67 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR}) 2 | include_directories(${AZURESTORAGE_INCLUDE_DIRS}) 3 | 4 | # THE ORDER OF FILES IS VERY /VERY/ IMPORTANT 5 | if(UNIX OR WIN32) 6 | set(SOURCES 7 | timer_handler.cpp 8 | executor.cpp 9 | xml_wrapper.cpp 10 | xmlhelpers.cpp 11 | response_parsers.cpp 12 | request_result.cpp 13 | request_factory.cpp 14 | protocol_xml.cpp 15 | navigation.cpp 16 | async_semaphore.cpp 17 | util.cpp 18 | table_request_factory.cpp 19 | table_response_parsers.cpp 20 | table_query.cpp 21 | entity_property.cpp 22 | shared_access_signature.cpp 23 | retry_policies.cpp 24 | resources.cpp 25 | queue_request_factory.cpp 26 | file_request_factory.cpp 27 | file_response_parsers.cpp 28 | protocol_json.cpp 29 | operation_context.cpp 30 | mime_multipart_helper.cpp 31 | logging.cpp 32 | hashing.cpp 33 | constants.cpp 34 | streams.cpp 35 | cloud_file_ostreambuf.cpp 36 | cloud_file.cpp 37 | cloud_file_directory.cpp 38 | cloud_file_share.cpp 39 | cloud_file_client.cpp 40 | cloud_table_client.cpp 41 | cloud_table.cpp 42 | cloud_storage_account.cpp 43 | cloud_queue_message.cpp 44 | cloud_queue_client.cpp 45 | cloud_queue.cpp 46 | cloud_page_blob.cpp 47 | cloud_core.cpp 48 | cloud_client.cpp 49 | cloud_block_blob.cpp 50 | cloud_blob_directory.cpp 51 | cloud_blob_container.cpp 52 | cloud_blob_shared.cpp 53 | cloud_blob_ostreambuf.cpp 54 | cloud_blob_istreambuf.cpp 55 | cloud_blob_client.cpp 56 | cloud_blob.cpp 57 | cloud_append_blob.cpp 58 | blob_response_parsers.cpp 59 | blob_request_factory.cpp 60 | basic_types.cpp 61 | authentication.cpp 62 | cloud_common.cpp 63 | crc64.cpp 64 | ) 65 | endif() 66 | 67 | if (APPLE) 68 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS}") 69 | else() 70 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 71 | endif() 72 | 73 | if(MSVC) 74 | add_compile_options(/Yustdafx.h) 75 | set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") 76 | 77 | if (NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") 78 | set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") 79 | set_property(SOURCE ${SOURCES} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") 80 | endif() 81 | 82 | list(APPEND SOURCES stdafx.cpp) 83 | endif() 84 | 85 | add_library(${AZURESTORAGE_LIBRARY} ${SOURCES}) 86 | 87 | target_link_libraries(${AZURESTORAGE_LIBRARIES}) 88 | 89 | if(WIN32) 90 | target_link_libraries(${AZURESTORAGE_LIBRARY} Ws2_32.lib rpcrt4.lib xmllite.lib bcrypt.lib) 91 | endif() 92 | 93 | # Portions specific to azure storage binary versioning and installation. 94 | if(UNIX) 95 | set_target_properties(${AZURESTORAGE_LIBRARY} PROPERTIES 96 | SOVERSION ${AZURESTORAGE_VERSION_MAJOR} 97 | VERSION ${AZURESTORAGE_VERSION_MAJOR}.${AZURESTORAGE_VERSION_MINOR}) 98 | 99 | elseif(WIN32) 100 | set_target_properties(${AZURESTORAGE_LIBRARY} PROPERTIES OUTPUT_NAME "wastorage") 101 | endif() 102 | 103 | install(FILES ${WAS_HEADERS} DESTINATION include/was) 104 | install(FILES ${WASCORE_HEADERS} DESTINATION include/wascore) 105 | install(FILES ${WASCORE_DATA} DESTINATION include/wascore) 106 | 107 | install( 108 | TARGETS ${AZURESTORAGE_LIBRARY} 109 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 110 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 111 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 112 | ) 113 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/async_semaphore.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/async_semaphore.h" 20 | 21 | namespace azure { namespace storage { namespace core { 22 | 23 | pplx::task _async_semaphore::lock_async() 24 | { 25 | pplx::extensibility::scoped_rw_lock_t guard(m_mutex); 26 | if (m_count > 0) 27 | { 28 | if (m_count-- == m_initial_count) 29 | { 30 | m_empty_event = pplx::task_completion_event(); 31 | } 32 | 33 | return pplx::task_from_result(); 34 | } 35 | else 36 | { 37 | pplx::task_completion_event pending; 38 | m_queue.push(pending); 39 | return pplx::create_task(pending); 40 | } 41 | } 42 | 43 | pplx::task _async_semaphore::wait_all_async() 44 | { 45 | return pplx::create_task(m_empty_event); 46 | } 47 | 48 | void _async_semaphore::unlock() 49 | { 50 | auto pending = dequeue_pending(); 51 | pending.set(); 52 | } 53 | 54 | pplx::task_completion_event _async_semaphore::dequeue_pending() 55 | { 56 | pplx::extensibility::scoped_rw_lock_t guard(m_mutex); 57 | if (m_queue.empty()) 58 | { 59 | if (++m_count == m_initial_count) 60 | { 61 | m_empty_event.set(); 62 | } 63 | 64 | return pplx::task_completion_event(); 65 | } 66 | else 67 | { 68 | auto pending = m_queue.front(); 69 | m_queue.pop(); 70 | return pending; 71 | } 72 | } 73 | 74 | }}} // namespace azure::storage::core 75 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/basic_types.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/basic_types.h" 20 | #include "wascore/resources.h" 21 | 22 | namespace utility { 23 | 24 | utility::uuid __cdecl new_uuid() 25 | { 26 | uuid result; 27 | 28 | #ifdef _WIN32 29 | RPC_STATUS status; 30 | 31 | status = UuidCreate(&result); 32 | if (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY && status != RPC_S_UUID_NO_ADDRESS) 33 | { 34 | throw std::runtime_error(azure::storage::protocol::error_create_uuid); 35 | } 36 | #else 37 | uuid_generate_random(result.data); 38 | #endif 39 | 40 | return result; 41 | } 42 | 43 | utility::string_t __cdecl uuid_to_string(const utility::uuid& value) 44 | { 45 | #ifdef _WIN32 46 | RPC_STATUS status; 47 | 48 | RPC_WSTR rpc_string; 49 | status = UuidToStringW(&value, &rpc_string); 50 | if (status != RPC_S_OK) 51 | { 52 | throw std::runtime_error(azure::storage::protocol::error_serialize_uuid); 53 | } 54 | 55 | std::wstring result(reinterpret_cast(rpc_string)); 56 | 57 | status = RpcStringFree(&rpc_string); 58 | if (status != RPC_S_OK) 59 | { 60 | throw std::runtime_error(azure::storage::protocol::error_free_uuid); 61 | } 62 | #else 63 | char uuid_string[37]; 64 | uuid_unparse_upper(value.data, uuid_string); 65 | 66 | std::string result(uuid_string); 67 | #endif 68 | 69 | return result; 70 | } 71 | 72 | utility::uuid __cdecl string_to_uuid(const utility::string_t& value) 73 | { 74 | uuid result; 75 | 76 | #ifdef _WIN32 77 | RPC_STATUS status; 78 | 79 | RPC_WSTR rpc_string = reinterpret_cast(const_cast(value.c_str())); 80 | 81 | status = UuidFromStringW(rpc_string, &result); 82 | if (status != RPC_S_OK) 83 | { 84 | throw std::runtime_error(azure::storage::protocol::error_parse_uuid); 85 | } 86 | #else 87 | int status_code = uuid_parse(value.c_str(), result.data); 88 | if (status_code != 0) 89 | { 90 | throw std::runtime_error(azure::storage::protocol::error_parse_uuid); 91 | } 92 | #endif 93 | 94 | return result; 95 | } 96 | 97 | bool __cdecl uuid_equal(const utility::uuid& value1, const utility::uuid& value2) 98 | { 99 | #ifdef _WIN32 100 | return value1 == value2; 101 | #else 102 | return uuid_compare(value1.data, value2.data) == 0; 103 | #endif 104 | } 105 | 106 | } // namespace utility 107 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_blob_directory.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/blob.h" 20 | #include "wascore/util.h" 21 | 22 | namespace azure { namespace storage { 23 | 24 | cloud_blob_directory::cloud_blob_directory(utility::string_t name, cloud_blob_container container) 25 | : m_name(std::move(name)), m_container(std::move(container)) 26 | { 27 | auto& delimiter = m_container.service_client().directory_delimiter(); 28 | if ((m_name.size() < delimiter.size()) || 29 | !std::equal(delimiter.crbegin(), delimiter.crend(), m_name.crbegin())) 30 | { 31 | m_name.append(delimiter); 32 | } 33 | 34 | m_uri = core::append_path_to_uri(m_container.uri(), m_name); 35 | } 36 | 37 | cloud_blob cloud_blob_directory::get_blob_reference(utility::string_t blob_name) const 38 | { 39 | return get_blob_reference(std::move(blob_name), utility::string_t()); 40 | } 41 | 42 | cloud_blob cloud_blob_directory::get_blob_reference(utility::string_t blob_name, utility::string_t snapshot_time) const 43 | { 44 | return cloud_blob(m_name + blob_name, std::move(snapshot_time), m_container); 45 | } 46 | 47 | cloud_page_blob cloud_blob_directory::get_page_blob_reference(utility::string_t blob_name) const 48 | { 49 | return get_page_blob_reference(std::move(blob_name), utility::string_t()); 50 | } 51 | 52 | cloud_page_blob cloud_blob_directory::get_page_blob_reference(utility::string_t blob_name, utility::string_t snapshot_time) const 53 | { 54 | return cloud_page_blob(m_name + blob_name, std::move(snapshot_time), m_container); 55 | } 56 | 57 | cloud_block_blob cloud_blob_directory::get_block_blob_reference(utility::string_t blob_name) const 58 | { 59 | return get_block_blob_reference(std::move(blob_name), utility::string_t()); 60 | } 61 | 62 | cloud_block_blob cloud_blob_directory::get_block_blob_reference(utility::string_t blob_name, utility::string_t snapshot_time) const 63 | { 64 | return cloud_block_blob(m_name + blob_name, std::move(snapshot_time), m_container); 65 | } 66 | 67 | cloud_append_blob cloud_blob_directory::get_append_blob_reference(utility::string_t blob_name) const 68 | { 69 | return get_block_blob_reference(std::move(blob_name), utility::string_t()); 70 | } 71 | 72 | cloud_append_blob cloud_blob_directory::get_append_blob_reference(utility::string_t blob_name, utility::string_t snapshot_time) const 73 | { 74 | return cloud_append_blob(m_name + blob_name, std::move(snapshot_time), m_container); 75 | } 76 | 77 | cloud_blob_directory cloud_blob_directory::get_subdirectory_reference(utility::string_t name) const 78 | { 79 | return cloud_blob_directory(m_name + name, m_container); 80 | } 81 | 82 | cloud_blob_directory cloud_blob_directory::get_parent_reference() const 83 | { 84 | utility::string_t parent_name(core::get_parent_name(m_name, m_container.service_client().directory_delimiter())); 85 | if (parent_name.empty()) 86 | { 87 | return cloud_blob_directory(); 88 | } 89 | else 90 | { 91 | return cloud_blob_directory(parent_name, m_container); 92 | } 93 | } 94 | 95 | list_blob_item_iterator cloud_blob_directory::list_blobs(bool use_flat_blob_listing, blob_listing_details::values includes, int max_results, const blob_request_options& options, operation_context context) const 96 | { 97 | return m_container.list_blobs(m_name, use_flat_blob_listing, includes, max_results, options, context); 98 | } 99 | 100 | pplx::task cloud_blob_directory::list_blobs_segmented_async(bool use_flat_blob_listing, blob_listing_details::values includes, int max_results, const continuation_token& token, const blob_request_options& options, operation_context context, const pplx::cancellation_token& cancellation_token) const 101 | { 102 | return m_container.list_blobs_segmented_async(m_name, use_flat_blob_listing, includes, max_results, token, options, context, cancellation_token); 103 | } 104 | 105 | }} // namespace azure::storage 106 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_blob_shared.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/blob.h" 20 | #include "wascore/protocol.h" 21 | #include "wascore/resources.h" 22 | 23 | namespace azure { namespace storage { 24 | 25 | void cloud_blob_container_properties::update_etag_and_last_modified(const cloud_blob_container_properties& parsed_properties) 26 | { 27 | m_etag = parsed_properties.etag(); 28 | m_last_modified = parsed_properties.last_modified(); 29 | } 30 | 31 | void cloud_blob_properties::update_etag_and_last_modified(const cloud_blob_properties& parsed_properties) 32 | { 33 | m_etag = parsed_properties.etag(); 34 | m_last_modified = parsed_properties.last_modified(); 35 | m_version_id = parsed_properties.version_id(); 36 | } 37 | 38 | void cloud_blob_properties::copy_from_root(const cloud_blob_properties& root_blob_properties) 39 | { 40 | m_size = root_blob_properties.m_size; 41 | m_etag = root_blob_properties.m_etag; 42 | m_last_modified = root_blob_properties.m_last_modified; 43 | m_type = root_blob_properties.m_type; 44 | m_page_blob_sequence_number = root_blob_properties.m_page_blob_sequence_number; 45 | m_cache_control = root_blob_properties.m_cache_control; 46 | m_content_disposition = root_blob_properties.m_content_disposition; 47 | m_content_encoding = root_blob_properties.m_content_encoding; 48 | m_content_language = root_blob_properties.m_content_language; 49 | m_content_md5 = root_blob_properties.m_content_md5; 50 | m_content_type = root_blob_properties.m_content_type; 51 | m_encryption_key_sha256 = root_blob_properties.m_encryption_key_sha256; 52 | } 53 | 54 | void cloud_blob_properties::update_size(const cloud_blob_properties& parsed_properties) 55 | { 56 | m_size = parsed_properties.size(); 57 | } 58 | 59 | void cloud_blob_properties::update_page_blob_sequence_number(const cloud_blob_properties& parsed_properties) 60 | { 61 | m_page_blob_sequence_number = parsed_properties.page_blob_sequence_number(); 62 | } 63 | 64 | void cloud_blob_properties::update_append_blob_committed_block_count(const cloud_blob_properties& parsed_properties) 65 | { 66 | m_append_blob_committed_block_count = parsed_properties.append_blob_committed_block_count(); 67 | } 68 | 69 | void cloud_blob_properties::update_all(const cloud_blob_properties& parsed_properties) 70 | { 71 | if ((type() != blob_type::unspecified) && (type() != parsed_properties.type())) 72 | { 73 | throw storage_exception(protocol::error_blob_type_mismatch, false); 74 | } 75 | 76 | *this = parsed_properties; 77 | } 78 | 79 | }} // namespace azure::storage 80 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_client.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/service_client.h" 20 | #include "wascore/protocol.h" 21 | #include "wascore/protocol_xml.h" 22 | 23 | namespace azure { namespace storage { 24 | 25 | pplx::task cloud_client::download_service_properties_base_async(const request_options& modified_options, operation_context context, const pplx::cancellation_token& cancellation_token) const 26 | { 27 | auto command = std::make_shared>(base_uri(), cancellation_token, modified_options.is_maximum_execution_time_customized()); 28 | command->set_build_request(std::bind(protocol::get_service_properties, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 29 | command->set_authentication_handler(authentication_handler()); 30 | command->set_location_mode(core::command_location_mode::primary_or_secondary); 31 | command->set_preprocess_response(std::bind(protocol::preprocess_response, service_properties(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 32 | command->set_postprocess_response([] (const web::http::http_response& response, const request_result&, const core::ostream_descriptor&, operation_context context) -> pplx::task 33 | { 34 | protocol::service_properties_reader reader(response.body()); 35 | return pplx::task_from_result(reader.move_properties()); 36 | }); 37 | return core::executor::execute_async(command, modified_options, context); 38 | } 39 | 40 | pplx::task cloud_client::upload_service_properties_base_async(const service_properties& properties, const service_properties_includes& includes, const request_options& modified_options, operation_context context, const pplx::cancellation_token& cancellation_token) const 41 | { 42 | protocol::service_properties_writer writer; 43 | concurrency::streams::istream stream(concurrency::streams::bytestream::open_istream(writer.write(properties, includes))); 44 | 45 | auto command = std::make_shared>(base_uri(), cancellation_token, modified_options.is_maximum_execution_time_customized()); 46 | command->set_build_request(std::bind(protocol::set_service_properties, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 47 | command->set_authentication_handler(authentication_handler()); 48 | command->set_preprocess_response(std::bind(protocol::preprocess_response_void, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 49 | return core::istream_descriptor::create(stream, checksum_type::none, std::numeric_limits::max(), std::numeric_limits::max(), command->get_cancellation_token()).then([command, context, modified_options, cancellation_token] (core::istream_descriptor request_body) -> pplx::task 50 | { 51 | command->set_request_body(request_body); 52 | return core::executor::execute_async(command, modified_options, context); 53 | }); 54 | } 55 | 56 | pplx::task cloud_client::download_service_stats_base_async(const request_options& modified_options, operation_context context, const pplx::cancellation_token& cancellation_token) const 57 | { 58 | if (modified_options.location_mode() == location_mode::primary_only) 59 | { 60 | throw storage_exception("download_service_stats cannot be run with a 'primary_only' location mode."); 61 | } 62 | 63 | auto command = std::make_shared>(base_uri(), cancellation_token, modified_options.is_maximum_execution_time_customized()); 64 | command->set_build_request(std::bind(protocol::get_service_stats, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 65 | command->set_authentication_handler(authentication_handler()); 66 | command->set_location_mode(core::command_location_mode::primary_or_secondary); 67 | command->set_preprocess_response(std::bind(protocol::preprocess_response, service_stats(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 68 | command->set_postprocess_response([] (const web::http::http_response& response, const request_result&, const core::ostream_descriptor&, operation_context context) -> pplx::task 69 | { 70 | protocol::service_stats_reader reader(response.body()); 71 | return pplx::task_from_result(reader.move_stats()); 72 | }); 73 | return core::executor::execute_async(command, modified_options, context); 74 | } 75 | 76 | } 77 | } // namespace azure::storage 78 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_common.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | 20 | #include "was/common.h" 21 | #include "wascore/resources.h" 22 | 23 | #ifdef _WIN32 24 | #include "Ws2tcpip.h" 25 | #else 26 | #include "boost/asio/ip/address.hpp" 27 | #endif 28 | 29 | namespace azure { namespace storage { 30 | 31 | WASTORAGE_API request_options::request_options() 32 | : m_location_mode(azure::storage::location_mode::primary_only), m_http_buffer_size(protocol::default_buffer_size),\ 33 | m_maximum_execution_time(protocol::default_maximum_execution_time), m_server_timeout(protocol::default_server_timeout),\ 34 | m_noactivity_timeout(protocol::default_noactivity_timeout),m_validate_certificates(protocol::default_validate_certificates) 35 | { 36 | } 37 | 38 | shared_access_policy::ip_address_or_range::ip_address shared_access_policy::ip_address_or_range::try_parse(const utility::string_t &address) 39 | { 40 | shared_access_policy::ip_address_or_range::ip_address ip; 41 | #ifdef _WIN32 42 | IN_ADDR addr; 43 | int ret = InetPton(AF_INET, address.data(), &addr); 44 | if (ret == 1) 45 | { 46 | ip.ipv4 = true; 47 | ip.addr = ntohl(addr.S_un.S_addr); 48 | return ip; 49 | } 50 | 51 | if (ret == -1) 52 | { 53 | throw utility::details::create_system_error(WSAGetLastError()); 54 | } 55 | 56 | if (ret == 0) 57 | { 58 | IN6_ADDR addr6; 59 | ret = InetPton(AF_INET6, address.data(), &addr6); 60 | if (ret == 1) 61 | { 62 | throw std::invalid_argument(protocol::error_ip_must_be_ipv4_in_sas); 63 | } 64 | 65 | if (ret == -1) 66 | { 67 | throw utility::details::create_system_error(WSAGetLastError()); 68 | } 69 | } 70 | 71 | throw std::invalid_argument(protocol::error_invalid_ip_address); 72 | #else 73 | boost::system::error_code error; 74 | auto addr = boost::asio::ip::address::from_string(address, error); 75 | if (error.value() == 0) 76 | { 77 | if (addr.is_v4()) 78 | { 79 | return addr; 80 | } 81 | 82 | throw std::invalid_argument(protocol::error_ip_must_be_ipv4_in_sas); 83 | } 84 | 85 | throw std::invalid_argument(protocol::error_invalid_ip_address); 86 | #endif 87 | } 88 | 89 | void shared_access_policy::ip_address_or_range::validate_range() 90 | { 91 | auto min_addr = try_parse(m_minimum_address); 92 | auto max_addr = try_parse(m_maximum_address); 93 | #ifdef _WIN32 94 | if (min_addr.addr > max_addr.addr) 95 | #else 96 | if (min_addr > max_addr) 97 | #endif 98 | { 99 | std::swap(m_minimum_address, m_maximum_address); 100 | } 101 | } 102 | 103 | }} // namespace azure::storage 104 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_core.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | 20 | #include "wascore/util.h" 21 | #include "wascore/resources.h" 22 | #include "was/core.h" 23 | 24 | namespace azure { namespace storage { 25 | 26 | #ifdef _WIN32 27 | static std::shared_ptr s_delayedScheduler; 28 | #endif 29 | 30 | storage_uri::storage_uri(web::http::uri primary_uri) 31 | : m_primary_uri(std::move(primary_uri)) 32 | { 33 | if (m_primary_uri.is_empty()) 34 | { 35 | throw std::invalid_argument(protocol::error_storage_uri_empty); 36 | } 37 | } 38 | 39 | storage_uri::storage_uri(web::http::uri primary_uri, web::http::uri secondary_uri) 40 | : m_primary_uri(std::move(primary_uri)), m_secondary_uri(std::move(secondary_uri)) 41 | { 42 | if (m_primary_uri.is_empty() && m_secondary_uri.is_empty()) 43 | { 44 | throw std::invalid_argument(protocol::error_storage_uri_empty); 45 | } 46 | 47 | // Validate the query and path match if both URIs are supplied 48 | if (!m_primary_uri.is_empty() && !m_secondary_uri.is_empty()) 49 | { 50 | if (m_primary_uri.query() != m_secondary_uri.query()) 51 | { 52 | throw std::invalid_argument(protocol::error_storage_uri_mismatch); 53 | } 54 | 55 | utility::string_t::size_type primary_path_start = core::find_path_start(m_primary_uri); 56 | utility::string_t::size_type secondary_path_start = core::find_path_start(m_secondary_uri); 57 | if (m_primary_uri.path().compare(primary_path_start, utility::string_t::npos, 58 | m_secondary_uri.path(), secondary_path_start, utility::string_t::npos) != 0) 59 | { 60 | throw std::invalid_argument(protocol::error_storage_uri_mismatch); 61 | } 62 | } 63 | } 64 | 65 | #ifdef _WIN32 66 | void __cdecl set_wastorage_ambient_scheduler(const std::shared_ptr& scheduler) 67 | { 68 | pplx::set_ambient_scheduler(scheduler); 69 | } 70 | 71 | const std::shared_ptr __cdecl get_wastorage_ambient_scheduler() 72 | { 73 | return pplx::get_ambient_scheduler(); 74 | } 75 | 76 | void __cdecl set_wastorage_ambient_delayed_scheduler(const std::shared_ptr& scheduler) 77 | { 78 | s_delayedScheduler = scheduler; 79 | } 80 | 81 | const std::shared_ptr& __cdecl get_wastorage_ambient_delayed_scheduler() 82 | { 83 | return s_delayedScheduler; 84 | } 85 | #endif 86 | 87 | }} // namespace azure::storage 88 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_file_ostreambuf.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/error_code_strings.h" 20 | #include "wascore/filestream.h" 21 | #include "wascore/logging.h" 22 | #include "wascore/resources.h" 23 | 24 | namespace azure { namespace storage { namespace core { 25 | 26 | pplx::task basic_cloud_file_ostreambuf::_sync() 27 | { 28 | upload_buffer(); 29 | 30 | auto this_pointer = std::dynamic_pointer_cast(shared_from_this()); 31 | return m_semaphore.wait_all_async().then([this_pointer]() -> pplx::task 32 | { 33 | if (this_pointer->m_currentException == nullptr) 34 | { 35 | return pplx::task_from_result(true); 36 | } 37 | else 38 | { 39 | return pplx::task_from_exception(this_pointer->m_currentException); 40 | } 41 | }); 42 | } 43 | 44 | pplx::task basic_cloud_file_ostreambuf::commit_close() 45 | { 46 | auto this_pointer = std::dynamic_pointer_cast(shared_from_this()); 47 | return _sync().then([this_pointer](bool) -> pplx::task 48 | { 49 | if (this_pointer->m_total_hash_provider.is_enabled()) 50 | { 51 | this_pointer->m_file->properties().set_content_md5(this_pointer->m_total_hash_provider.hash().md5()); 52 | return this_pointer->m_file->upload_properties_async(this_pointer->m_condition, this_pointer->m_options, this_pointer->m_context); 53 | } 54 | 55 | return pplx::task_from_result(); 56 | }); 57 | } 58 | 59 | pplx::task basic_cloud_file_ostreambuf::upload_buffer() 60 | { 61 | auto buffer = prepare_buffer(); 62 | if (buffer->is_empty()) 63 | { 64 | return pplx::task_from_result(); 65 | } 66 | 67 | auto offset = m_current_file_offset; 68 | m_current_file_offset += buffer->size(); 69 | 70 | auto this_pointer = std::dynamic_pointer_cast(shared_from_this()); 71 | return m_semaphore.lock_async().then([this_pointer, buffer, offset]() 72 | { 73 | if (this_pointer->m_currentException == nullptr) 74 | { 75 | try 76 | { 77 | this_pointer->m_file->write_range_async(buffer->stream(), offset, buffer->content_checksum().md5(), this_pointer->m_condition, this_pointer->m_options, this_pointer->m_context).then([this_pointer](pplx::task upload_task) 78 | { 79 | std::lock_guard guard(this_pointer->m_semaphore, std::adopt_lock); 80 | try 81 | { 82 | upload_task.wait(); 83 | } 84 | catch (const std::exception&) 85 | { 86 | this_pointer->m_currentException = std::current_exception(); 87 | } 88 | }); 89 | } 90 | catch (...) 91 | { 92 | this_pointer->m_semaphore.unlock(); 93 | } 94 | } 95 | else 96 | { 97 | this_pointer->m_semaphore.unlock(); 98 | } 99 | }); 100 | } 101 | 102 | }}} // namespace azure::storage::core 103 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/cloud_queue_message.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/queue.h" 20 | 21 | namespace azure { namespace storage { 22 | 23 | const std::chrono::seconds max_time_to_live(std::chrono::system_clock::duration::max().count()); 24 | 25 | void cloud_queue_message::update_message_info(const cloud_queue_message& message_metadata) 26 | { 27 | m_id = message_metadata.m_id; 28 | m_insertion_time = message_metadata.m_insertion_time; 29 | m_expiration_time = message_metadata.m_expiration_time; 30 | m_pop_receipt = message_metadata.m_pop_receipt; 31 | m_next_visible_time = message_metadata.m_next_visible_time; 32 | } 33 | 34 | }} // namespace azure::storage 35 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/constants.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License") 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/constants.h" 20 | #include "wascore/basic_types.h" 21 | 22 | namespace azure { namespace storage { namespace protocol { 23 | 24 | #define _CONSTANTS 25 | #define DAT(a, b) WASTORAGE_API const utility::char_t a[] = b; 26 | #include "wascore/constants.dat" 27 | #undef DAT 28 | #undef _CONSTANTS 29 | 30 | }}} // namespace azure::storage::protocol 31 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/mime_multipart_helper.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/util.h" 20 | #include "was/table.h" 21 | 22 | namespace azure { namespace storage { namespace core { 23 | 24 | utility::string_t generate_boundary_name(const utility::string_t& prefix) 25 | { 26 | utility::uuid id = utility::new_uuid(); 27 | 28 | utility::string_t boundary_name; 29 | boundary_name.reserve(prefix.size() + 37); 30 | 31 | boundary_name.append(prefix); 32 | boundary_name.push_back(_XPLATSTR('_')); 33 | boundary_name.append(utility::uuid_to_string(id)); 34 | 35 | return boundary_name; 36 | } 37 | 38 | void write_line_break(utility::string_t& body_text) 39 | { 40 | body_text.push_back(_XPLATSTR('\r')); 41 | body_text.push_back(_XPLATSTR('\n')); 42 | } 43 | 44 | void write_boundary(utility::string_t& body_text, const utility::string_t& boundary_name, bool is_closure) 45 | { 46 | body_text.append(_XPLATSTR("--")); 47 | body_text.append(boundary_name); 48 | if (is_closure) 49 | { 50 | body_text.append(_XPLATSTR("--")); 51 | } 52 | 53 | write_line_break(body_text); 54 | } 55 | 56 | void write_mime_changeset_headers(utility::string_t& body_text) 57 | { 58 | body_text.append(web::http::header_names::content_type); 59 | body_text.push_back(_XPLATSTR(':')); 60 | body_text.push_back(_XPLATSTR(' ')); 61 | body_text.append(protocol::header_value_content_type_http); 62 | write_line_break(body_text); 63 | 64 | body_text.append(protocol::header_content_transfer_encoding); 65 | body_text.push_back(_XPLATSTR(':')); 66 | body_text.push_back(_XPLATSTR(' ')); 67 | body_text.append(protocol::header_value_content_transfer_encoding_binary); 68 | write_line_break(body_text); 69 | 70 | write_line_break(body_text); 71 | } 72 | 73 | void write_request_line(utility::string_t& body_text, const web::http::method& method, const web::http::uri& uri) 74 | { 75 | body_text.append(method); 76 | body_text.push_back(_XPLATSTR(' ')); 77 | body_text.append(uri.to_string()); 78 | body_text.push_back(_XPLATSTR(' ')); 79 | body_text.append(protocol::http_version); 80 | write_line_break(body_text); 81 | } 82 | 83 | void write_request_headers(utility::string_t& body_text, const web::http::http_headers& headers) 84 | { 85 | for (web::http::http_headers::const_iterator it = headers.begin(); it != headers.end(); ++it) 86 | { 87 | const utility::string_t& header_name = it->first; 88 | const utility::string_t& header_value = it->second; 89 | 90 | body_text.append(header_name); 91 | body_text.push_back(_XPLATSTR(':')); 92 | body_text.push_back(_XPLATSTR(' ')); 93 | body_text.append(header_value); 94 | write_line_break(body_text); 95 | } 96 | 97 | write_line_break(body_text); 98 | } 99 | 100 | void write_request_payload(utility::string_t& body_text, const web::json::value& json_object) 101 | { 102 | if (!json_object.is_null()) 103 | { 104 | body_text.append(json_object.serialize()); 105 | } 106 | 107 | write_line_break(body_text); 108 | } 109 | 110 | }}} // namespace azure::storage::core 111 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/operation_context.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/service_client.h" 20 | 21 | namespace azure { namespace storage { 22 | 23 | client_log_level operation_context::m_global_log_level = client_log_level::log_level_off; 24 | 25 | web::web_proxy operation_context::m_global_proxy; 26 | 27 | operation_context::operation_context() 28 | : m_impl(std::make_shared<_operation_context>()) 29 | { 30 | set_log_level(default_log_level()); 31 | set_proxy(default_proxy()); 32 | set_client_request_id(utility::uuid_to_string(utility::new_uuid())); 33 | } 34 | 35 | client_log_level operation_context::default_log_level() 36 | { 37 | return m_global_log_level; 38 | } 39 | 40 | void operation_context::set_default_log_level(client_log_level log_level) 41 | { 42 | m_global_log_level = log_level; 43 | } 44 | 45 | const web::web_proxy &operation_context::default_proxy() 46 | { 47 | return m_global_proxy; 48 | } 49 | 50 | void operation_context::set_default_proxy(web::web_proxy proxy) 51 | { 52 | m_global_proxy = std::move(proxy); 53 | } 54 | 55 | }} // namespace azure::storage 56 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/request_factory.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/protocol.h" 20 | #include "wascore/constants.h" 21 | 22 | namespace azure { namespace storage { namespace protocol { 23 | 24 | web::http::http_request base_request(web::http::method method, web::http::uri_builder& uri_builder, const std::chrono::seconds& timeout, operation_context context) 25 | { 26 | UNREFERENCED_PARAMETER(context); 27 | if (timeout.count() > 0) 28 | { 29 | uri_builder.append_query(core::make_query_parameter(uri_query_timeout, timeout.count(), /* do_encoding */ false)); 30 | } 31 | 32 | web::http::http_request request(method); 33 | request.set_request_uri(uri_builder.to_uri()); 34 | 35 | web::http::http_headers& headers = request.headers(); 36 | headers.add(web::http::header_names::user_agent, header_value_user_agent); 37 | headers.add(ms_header_version, header_value_storage_version); 38 | 39 | if (method == web::http::methods::PUT) 40 | { 41 | headers.set_content_length(0); 42 | } 43 | 44 | return request; 45 | } 46 | 47 | web::http::http_request get_service_properties(web::http::uri_builder& uri_builder, const std::chrono::seconds& timeout, operation_context context) 48 | { 49 | uri_builder.append_query(core::make_query_parameter(uri_query_resource_type, resource_service, /* do_encoding */ false)); 50 | uri_builder.append_query(core::make_query_parameter(uri_query_component, component_properties, /* do_encoding */ false)); 51 | web::http::http_request request(base_request(web::http::methods::GET, uri_builder, timeout, context)); 52 | return request; 53 | } 54 | 55 | web::http::http_request set_service_properties(web::http::uri_builder& uri_builder, const std::chrono::seconds& timeout, operation_context context) 56 | { 57 | uri_builder.append_query(core::make_query_parameter(uri_query_resource_type, resource_service, /* do_encoding */ false)); 58 | uri_builder.append_query(core::make_query_parameter(uri_query_component, component_properties, /* do_encoding */ false)); 59 | web::http::http_request request(base_request(web::http::methods::PUT, uri_builder, timeout, context)); 60 | return request; 61 | } 62 | 63 | web::http::http_request get_service_stats(web::http::uri_builder& uri_builder, const std::chrono::seconds& timeout, operation_context context) 64 | { 65 | uri_builder.append_query(uri_query_resource_type, resource_service); 66 | uri_builder.append_query(uri_query_component, component_stats); 67 | web::http::http_request request(base_request(web::http::methods::GET, uri_builder, timeout, context)); 68 | return request; 69 | } 70 | 71 | web::http::http_request get_account_properties(web::http::uri_builder& uri_builder, const std::chrono::seconds& timeout, operation_context context) 72 | { 73 | uri_builder.append_query(uri_query_resource_type, resource_account); 74 | uri_builder.append_query(uri_query_component, component_properties); 75 | web::http::http_request request(base_request(web::http::methods::GET, uri_builder, timeout, context)); 76 | return request; 77 | } 78 | 79 | void add_optional_header(web::http::http_headers& headers, const utility::string_t& header, const utility::string_t& value) 80 | { 81 | if (!value.empty()) 82 | { 83 | headers.add(header, value); 84 | } 85 | } 86 | 87 | void add_metadata(web::http::http_request& request, const cloud_metadata& metadata) 88 | { 89 | web::http::http_headers& headers = request.headers(); 90 | for (cloud_metadata::const_iterator it = metadata.cbegin(); it != metadata.cend(); ++it) 91 | { 92 | if (core::has_whitespace_or_empty(it->first)) 93 | { 94 | throw std::invalid_argument(protocol::error_empty_whitespace_metadata_name); 95 | } 96 | if (core::is_empty_or_whitespace(it->second)) 97 | { 98 | throw std::invalid_argument(protocol::error_empty_metadata_value); 99 | } 100 | if (isspace(*it->second.begin()) || isspace(*it->second.rbegin())) 101 | { 102 | headers.add(ms_header_metadata_prefix + it->first, core::str_trim_starting_trailing_whitespaces(it->second)); 103 | } 104 | else 105 | { 106 | headers.add(ms_header_metadata_prefix + it->first, it->second); 107 | } 108 | 109 | } 110 | } 111 | 112 | }}} // namespace azure::storage::protocol 113 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/request_result.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/common.h" 20 | #include "wascore/protocol.h" 21 | #include "wascore/util.h" 22 | #include "wascore/constants.h" 23 | 24 | namespace azure { namespace storage { 25 | 26 | request_result::request_result(utility::datetime start_time, storage_location target_location, const web::http::http_response& response, bool parse_body_as_error) 27 | : m_is_response_available(true), 28 | m_start_time(start_time), 29 | m_target_location(target_location), 30 | m_end_time(utility::datetime::utc_now()), 31 | m_http_status_code(response.status_code()), 32 | m_content_length(std::numeric_limits::max()), 33 | m_request_server_encrypted(false) 34 | { 35 | parse_headers(response.headers()); 36 | if (parse_body_as_error) 37 | { 38 | parse_body(response); 39 | } 40 | } 41 | 42 | request_result::request_result(utility::datetime start_time, storage_location target_location, const web::http::http_response& response, web::http::status_code http_status_code, storage_extended_error extended_error) 43 | : m_is_response_available(true), 44 | m_start_time(start_time), 45 | m_target_location(target_location), 46 | m_end_time(utility::datetime::utc_now()), 47 | m_http_status_code(http_status_code), 48 | m_extended_error(std::move(extended_error)), 49 | m_content_length(std::numeric_limits::max()), 50 | m_request_server_encrypted(false) 51 | { 52 | parse_headers(response.headers()); 53 | } 54 | 55 | void request_result::parse_headers(const web::http::http_headers& headers) 56 | { 57 | headers.match(protocol::ms_header_request_id, m_service_request_id); 58 | headers.match(web::http::header_names::content_length, m_content_length); 59 | headers.match(web::http::header_names::content_md5, m_content_md5); 60 | headers.match(protocol::ms_header_content_crc64, m_content_crc64); 61 | headers.match(web::http::header_names::etag, m_etag); 62 | 63 | utility::string_t request_server_encrypted; 64 | if (headers.match(protocol::ms_header_request_server_encrypted, request_server_encrypted)) 65 | { 66 | m_request_server_encrypted = (request_server_encrypted == _XPLATSTR("true")); 67 | } 68 | 69 | utility::string_t request_date; 70 | if (headers.match(web::http::header_names::date, request_date)) 71 | { 72 | m_request_date = utility::datetime::from_string(request_date, utility::datetime::date_format::RFC_1123); 73 | } 74 | } 75 | 76 | void request_result::parse_body(const web::http::http_response& response) 77 | { 78 | m_extended_error = protocol::parse_extended_error(response); 79 | } 80 | 81 | }} // namespace azure::storage 82 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/resources.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License") 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/resources.h" 20 | #include "wascore/basic_types.h" 21 | 22 | namespace azure { namespace storage { namespace protocol { 23 | 24 | #define _RESOURCES 25 | #define DAT(a, b) const char* a = b; 26 | #include "wascore/constants.dat" 27 | #undef DAT 28 | #undef _RESOURCES 29 | 30 | }}} // namespace azure::storage::protocol 31 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | // stdafx.cpp : source file that includes just the standard includes 19 | // Microsoft.WindowsAzure.Storage.pch will be the pre-compiled header 20 | // stdafx.obj will contain the pre-compiled type information 21 | 22 | #include "stdafx.h" 23 | 24 | // TODO: reference any additional headers you need in STDAFX.H 25 | // and not in this file 26 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/streams.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/error_code_strings.h" 20 | #include "wascore/blobstreams.h" 21 | #include "wascore/logging.h" 22 | #include "wascore/resources.h" 23 | 24 | namespace azure { namespace storage { namespace core { 25 | 26 | 27 | pplx::task basic_cloud_ostreambuf::_close_write() 28 | { 29 | if (m_committed) 30 | { 31 | throw std::logic_error(protocol::error_closed_stream); 32 | } 33 | 34 | m_committed = true; 35 | basic_ostreambuf::_close_write().wait(); 36 | 37 | if (m_total_hash_provider.is_enabled()) 38 | { 39 | m_total_hash_provider.close(); 40 | } 41 | 42 | return commit_close(); 43 | } 44 | 45 | std::shared_ptr basic_cloud_ostreambuf::prepare_buffer() 46 | { 47 | checksum block_checksum; 48 | if (m_transaction_hash_provider.is_enabled()) 49 | { 50 | m_transaction_hash_provider.close(); 51 | block_checksum = m_transaction_hash_provider.hash(); 52 | if (block_checksum.is_md5()) 53 | { 54 | m_transaction_hash_provider = hash_provider::create_md5_hash_provider(); 55 | } 56 | else if (block_checksum.is_crc64()) 57 | { 58 | m_transaction_hash_provider = hash_provider::create_crc64_hash_provider(); 59 | } 60 | } 61 | 62 | auto buffer = std::make_shared(m_buffer, block_checksum); 63 | m_buffer = concurrency::streams::container_buffer>(); 64 | m_buffer_size = m_next_buffer_size; 65 | return buffer; 66 | } 67 | 68 | pplx::task basic_cloud_ostreambuf::_putc(concurrency::streams::ostream::traits::char_type ch) 69 | { 70 | pplx::task upload_task = pplx::task_from_result(); 71 | 72 | m_current_streambuf_offset += 1; 73 | auto result = m_buffer.putc(ch).get(); 74 | if (m_buffer_size == m_buffer.in_avail()) 75 | { 76 | upload_task = upload_buffer(); 77 | } 78 | 79 | return upload_task.then([result]() -> basic_cloud_ostreambuf::int_type 80 | { 81 | return result; 82 | }); 83 | } 84 | 85 | pplx::task basic_cloud_ostreambuf::_putn(const concurrency::streams::ostream::traits::char_type* ptr, size_t count) 86 | { 87 | pplx::task upload_task = pplx::task_from_result(); 88 | 89 | m_current_streambuf_offset += count; 90 | auto remaining = count; 91 | while (remaining > 0) 92 | { 93 | auto write_size = m_buffer_size - static_cast(m_buffer.size()); 94 | if (write_size > remaining) 95 | { 96 | write_size = remaining; 97 | } 98 | 99 | if (m_transaction_hash_provider.is_enabled()) 100 | { 101 | m_transaction_hash_provider.write(ptr, write_size); 102 | } 103 | 104 | if (m_total_hash_provider.is_enabled()) 105 | { 106 | m_total_hash_provider.write(ptr, write_size); 107 | } 108 | 109 | // The streambuf is waited because it is a memory buffer, so does not involve async I/O 110 | m_buffer.putn_nocopy(ptr, write_size).wait(); 111 | if (m_buffer_size == m_buffer.size()) 112 | { 113 | upload_task = upload_buffer(); 114 | } 115 | 116 | ptr += write_size; 117 | remaining -= write_size; 118 | } 119 | 120 | return upload_task.then([count]() -> size_t 121 | { 122 | return count; 123 | }); 124 | } 125 | 126 | }}} // azure::storage::core -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/table_query.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "was/table.h" 20 | #include "wascore/util.h" 21 | 22 | namespace azure { namespace storage { 23 | 24 | const utility::string_t table_query::generate_filter_condition(const utility::string_t& property_name, const utility::string_t& comparison_operator, const utility::string_t& value) 25 | { 26 | utility::string_t modified_value = core::single_quote(value); 27 | return generate_filter_condition_impl(property_name, comparison_operator, modified_value); 28 | } 29 | 30 | const utility::string_t table_query::generate_filter_condition(const utility::string_t& property_name, const utility::string_t& comparison_operator, const std::vector& value) 31 | { 32 | utility::string_t string_data_value = core::convert_to_string(value); 33 | 34 | utility::string_t string_value; 35 | string_value.reserve(string_data_value.size() + 3U); 36 | 37 | string_value.append(_XPLATSTR("X'")); 38 | string_value.append(string_data_value); 39 | string_value.push_back(_XPLATSTR('\'')); 40 | 41 | return generate_filter_condition_impl(property_name, comparison_operator, string_value); 42 | } 43 | 44 | const utility::string_t table_query::generate_filter_condition(const utility::string_t& property_name, const utility::string_t& comparison_operator, double value) 45 | { 46 | utility::string_t string_value = core::convert_to_string(value); 47 | return generate_filter_condition_impl(property_name, comparison_operator, string_value); 48 | } 49 | 50 | const utility::string_t table_query::generate_filter_condition(const utility::string_t& property_name, const utility::string_t& comparison_operator, int32_t value) 51 | { 52 | utility::string_t string_value = core::convert_to_string(value); 53 | return generate_filter_condition_impl(property_name, comparison_operator, string_value); 54 | } 55 | 56 | const utility::string_t table_query::generate_filter_condition_impl(const utility::string_t& property_name, const utility::string_t& comparison_operator, const utility::string_t& value) 57 | { 58 | utility::string_t result; 59 | result.reserve(property_name.size() + comparison_operator.size() + value.size() + 2U); 60 | 61 | result.append(property_name); 62 | result.push_back(_XPLATSTR(' ')); 63 | result.append(comparison_operator); 64 | result.push_back(_XPLATSTR(' ')); 65 | result.append(value); 66 | 67 | return result; 68 | } 69 | 70 | }} // namespace azure::storage 71 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/src/timer_handler.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2018 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "wascore/timer_handler.h" 20 | 21 | namespace azure { namespace storage { namespace core { 22 | 23 | timer_handler::timer_handler(const pplx::cancellation_token& token) : 24 | m_cancellation_token(token), m_is_canceled_by_timeout(false), m_timer_started(false) 25 | { 26 | if (m_cancellation_token != pplx::cancellation_token::none()) 27 | { 28 | m_cancellation_token_registration = m_cancellation_token.register_callback([this]() 29 | { 30 | m_worker_cancellation_token_source.cancel(); 31 | stop_timer(); 32 | }); 33 | } 34 | } 35 | 36 | timer_handler::~timer_handler() 37 | { 38 | if (m_cancellation_token != pplx::cancellation_token::none()) 39 | { 40 | m_cancellation_token.deregister_callback(m_cancellation_token_registration); 41 | } 42 | 43 | stop_timer(); 44 | } 45 | 46 | void timer_handler::start_timer(const std::chrono::milliseconds& time) 47 | { 48 | std::lock_guard guard(m_mutex); 49 | if (m_timer_started.load(std::memory_order_acquire)) 50 | { 51 | return; 52 | } 53 | m_timer_started.store(true, std::memory_order_release); 54 | std::weak_ptr weak_this_pointer = shared_from_this(); 55 | m_timeout_task = timeout_after(time).then([weak_this_pointer]() 56 | { 57 | auto this_pointer = weak_this_pointer.lock(); 58 | if (this_pointer) 59 | { 60 | this_pointer->m_is_canceled_by_timeout.store(true, std::memory_order_release); 61 | this_pointer->m_worker_cancellation_token_source.cancel(); 62 | } 63 | }); 64 | } 65 | 66 | void timer_handler::stop_timer() 67 | { 68 | std::lock_guard guard(m_mutex); 69 | if (m_timer_started.load(std::memory_order_acquire) && m_timer) 70 | { 71 | #ifndef _WIN32 72 | m_timer->cancel(); 73 | #else 74 | m_timer->stop(); 75 | #endif 76 | if (!m_tce._IsTriggered()) 77 | { 78 | // If task_completion_event is not yet triggered, it means timeout has not been triggered. 79 | m_tce._Cancel(); 80 | } 81 | m_timer.reset(); 82 | } 83 | } 84 | 85 | #ifndef _WIN32 86 | pplx::task timer_handler::timeout_after(const std::chrono::milliseconds& time) 87 | { 88 | m_timer = std::make_shared>(crossplat::threadpool::shared_instance().service()); 89 | m_timer->expires_from_now(std::chrono::duration_cast(time)); 90 | std::weak_ptr weak_this_pointer = shared_from_this(); 91 | auto callback = [weak_this_pointer](const boost::system::error_code& ec) 92 | { 93 | if (ec != boost::asio::error::operation_aborted) 94 | { 95 | auto this_pointer = weak_this_pointer.lock(); 96 | if (this_pointer) 97 | { 98 | std::lock_guard guard(this_pointer->m_mutex); 99 | if (!this_pointer->m_tce._IsTriggered()) 100 | { 101 | this_pointer->m_tce.set(); 102 | } 103 | } 104 | } 105 | }; 106 | m_timer->async_wait(callback); 107 | 108 | auto event_set = pplx::create_task(m_tce); 109 | 110 | return event_set.then([callback]() {}); 111 | } 112 | #else 113 | pplx::task timer_handler::timeout_after(const std::chrono::milliseconds& time) 114 | { 115 | // Initialize the timer and connect the callback with completion event. 116 | m_timer = std::make_shared>(static_cast(time.count()), 0); 117 | std::weak_ptr weak_this_pointer = shared_from_this(); 118 | auto callback = std::make_shared>([weak_this_pointer](int) 119 | { 120 | auto this_pointer = weak_this_pointer.lock(); 121 | if (this_pointer) 122 | { 123 | std::lock_guard guard(this_pointer->m_mutex); 124 | if (!this_pointer->m_tce._IsTriggered()) 125 | { 126 | this_pointer->m_tce.set(); 127 | } 128 | } 129 | }); 130 | m_timer->link_target(callback.get()); // When timer stops, tce will trigger cancellation. 131 | m_timer->start(); 132 | 133 | auto event_set = pplx::create_task(m_tce); 134 | 135 | // Timer and callback should be preserved before event set has been triggered. 136 | return event_set.then([callback]() {}); 137 | } 138 | #endif 139 | 140 | }}} 141 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(../includes ${AZURESTORAGE_INCLUDE_DIRS} ${UnitTest++_INCLUDE_DIRS}) 2 | 3 | # THE ORDER OF FILES IS VERY /VERY/ IMPORTANT 4 | if(UNIX) 5 | set(SOURCES 6 | timer_handler_test.cpp 7 | blob_lease_test.cpp 8 | blob_streams_test.cpp 9 | blob_test_base.cpp 10 | cloud_append_blob_test.cpp 11 | cloud_blob_client_test.cpp 12 | cloud_blob_container_test.cpp 13 | cloud_blob_directory_test.cpp 14 | cloud_blob_test.cpp 15 | cloud_block_blob_test.cpp 16 | cloud_page_blob_test.cpp 17 | cloud_queue_client_test.cpp 18 | cloud_queue_test.cpp 19 | cloud_storage_account_test.cpp 20 | cloud_table_client_test.cpp 21 | cloud_table_test.cpp 22 | cloud_file_test.cpp 23 | cloud_file_directory_test.cpp 24 | cloud_file_share_test.cpp 25 | cloud_file_client_test.cpp 26 | file_test_base.cpp 27 | executor_test.cpp 28 | main.cpp 29 | queue_test_base.cpp 30 | read_from_secondary_test.cpp 31 | result_iterator_test.cpp 32 | retry_policy_test.cpp 33 | service_properties_test.cpp 34 | stdafx.cpp 35 | storage_exception_test.cpp 36 | table_test_base.cpp 37 | test_base.cpp 38 | unicode_test.cpp 39 | ) 40 | endif() 41 | 42 | add_executable(${AZURESTORAGE_LIBRARY_TEST} ${SOURCES}) 43 | 44 | target_link_libraries(${AZURESTORAGE_LIBRARY_TEST} ${AZURESTORAGE_LIBRARIES} ${UnitTest++_LIBRARIES}) 45 | 46 | # Copy test configuration to output directory 47 | file(COPY test_configurations.json DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 48 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/Microsoft.WindowsAzure.Storage.UnitTests.v140.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Source Files 70 | 71 | 72 | Source Files 73 | 74 | 75 | Source Files 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Source Files 85 | 86 | 87 | Source Files 88 | 89 | 90 | Source Files 91 | 92 | 93 | Source Files 94 | 95 | 96 | Source Files 97 | 98 | 99 | Source Files 100 | 101 | 102 | Source Files 103 | 104 | 105 | Source Files 106 | 107 | 108 | Source Files 109 | 110 | 111 | Source Files 112 | 113 | 114 | Source Files 115 | 116 | 117 | Source Files 118 | 119 | 120 | Source Files 121 | 122 | 123 | Source Files 124 | 125 | 126 | Source Files 127 | 128 | 129 | Source Files 130 | 131 | 132 | Source Files 133 | 134 | 135 | Source Files 136 | 137 | 138 | Source Files 139 | 140 | 141 | Source Files 142 | 143 | 144 | Source Files 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/README.md: -------------------------------------------------------------------------------- 1 | # Unit Tests for Azure Storage Client Library for C++ 2 | 3 | ## Prerequisites 4 | Run following commands under root of this repository to get UnitTest++. 5 | ```bash 6 | git submodule init 7 | git submodule update 8 | ``` 9 | 10 | ## Running the tests 11 | 12 | The unit tests run against real Azure services. If you have an Azure Storage 13 | account, change the values in `test_configurations.json` to point to it. *Do 14 | not push these changes to GitHub, as doing so will expose your account key 15 | to everyone.* 16 | 17 | Alternatively, you can change the "target" in `test_configurations.json` to 18 | "devstore". Then the tests will be run against the 19 | [Azure Storage Emulator](https://azure.microsoft.com/en-us/documentation/articles/storage-use-emulator/) 20 | (which can be installed as part of the 21 | [Azure SDK](https://azure.microsoft.com/downloads/)). Some tests will fail 22 | under this configuration, as the emulator doesn't support all of the 23 | features the tests use. 24 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/check_macros.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #define CHECK_UTF8_EQUAL(expected, actual) CHECK_EQUAL(utility::conversions::to_utf8string(expected), utility::conversions::to_utf8string(actual)) 21 | 22 | #define CHECK_STORAGE_EXCEPTION(expression, expected_message) \ 23 | do \ 24 | { \ 25 | bool caught_ = false; \ 26 | std::string returned_message; \ 27 | try { expression; } \ 28 | catch (const azure::storage::storage_exception& ex) { \ 29 | returned_message = ex.what(); \ 30 | caught_ = true; \ 31 | } \ 32 | catch (...) {} \ 33 | if (!caught_) \ 34 | UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "storage_exception not thrown"); \ 35 | else { \ 36 | try { \ 37 | UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected_message, returned_message, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ 38 | } \ 39 | catch (...) { \ 40 | UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ 41 | "Unhandled exception in CHECK_STORAGE_EXCEPTION"); \ 42 | } \ 43 | } \ 44 | } while(0) 45 | 46 | #define CHECK_NOTHROW(expression) \ 47 | do \ 48 | { \ 49 | bool exception_thrown = false; \ 50 | try { expression; } \ 51 | catch (...) { exception_thrown = true; } \ 52 | if (exception_thrown) \ 53 | UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Expected no exception thrown: \"" #expression "\"."); \ 54 | } while(0) 55 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/checksum_test.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2019 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "check_macros.h" 20 | #include "was/core.h" 21 | 22 | SUITE(Core) 23 | { 24 | TEST(checksum_class) 25 | { 26 | CHECK(azure::storage::checksum_type::none == azure::storage::checksum_none_t::value); 27 | CHECK(azure::storage::checksum_type::md5 == azure::storage::checksum_md5_t::value); 28 | CHECK(azure::storage::checksum_type::crc64 == azure::storage::checksum_crc64_t::value); 29 | CHECK(azure::storage::checksum_type::hmac_sha256 == azure::storage::checksum_hmac_sha256_t::value); 30 | CHECK(azure::storage::checksum_type::none == azure::storage::checksum_none.value); 31 | CHECK(azure::storage::checksum_type::md5 == azure::storage::checksum_md5.value); 32 | CHECK(azure::storage::checksum_type::crc64 == azure::storage::checksum_crc64.value); 33 | CHECK(azure::storage::checksum_type::hmac_sha256 == azure::storage::checksum_hmac_sha256.value); 34 | 35 | const utility::char_t* md5_cstr = _XPLATSTR("1B2M2Y8AsgTpgAmY7PhCfg=="); 36 | const utility::string_t md5_str(md5_cstr); 37 | const uint64_t crc64_val = 0x0; 38 | const utility::string_t crc64_str(_XPLATSTR("AAAAAAAAAAA=")); 39 | const utility::string_t hmac_sha256_str(_XPLATSTR("H3MaxXPHmTz2iCz6XIggaMFNXVI0gCqYsU/BChVkrHE=")); 40 | 41 | { 42 | azure::storage::checksum cs; 43 | CHECK(!cs.is_md5()); 44 | CHECK(!cs.is_crc64()); 45 | CHECK(!cs.is_hmac_sha256()); 46 | CHECK(cs.empty()); 47 | } 48 | { 49 | azure::storage::checksum cs(azure::storage::checksum_none); 50 | CHECK(!cs.is_md5()); 51 | CHECK(!cs.is_crc64()); 52 | CHECK(!cs.is_hmac_sha256()); 53 | CHECK(cs.empty()); 54 | } 55 | { 56 | // For backward compatibility. 57 | utility::string_t empty_string; 58 | azure::storage::checksum cs(empty_string); 59 | CHECK(!cs.is_md5()); 60 | CHECK(!cs.is_crc64()); 61 | CHECK(!cs.is_hmac_sha256()); 62 | CHECK(cs.empty()); 63 | } 64 | { 65 | azure::storage::checksum cs(md5_str); 66 | CHECK(cs.is_md5()); 67 | CHECK(!cs.is_crc64()); 68 | CHECK(!cs.is_hmac_sha256()); 69 | CHECK(!cs.empty()); 70 | CHECK_UTF8_EQUAL(cs.md5(), md5_str); 71 | } 72 | { 73 | azure::storage::checksum cs(md5_cstr); 74 | CHECK(cs.is_md5()); 75 | CHECK(!cs.is_crc64()); 76 | CHECK(!cs.is_hmac_sha256()); 77 | CHECK(!cs.empty()); 78 | CHECK_UTF8_EQUAL(cs.md5(), md5_str); 79 | } 80 | { 81 | azure::storage::checksum cs(azure::storage::checksum_md5, md5_str); 82 | CHECK(cs.is_md5()); 83 | CHECK(!cs.is_crc64()); 84 | CHECK(!cs.is_hmac_sha256()); 85 | CHECK(!cs.empty()); 86 | CHECK_UTF8_EQUAL(cs.md5(), md5_str); 87 | } 88 | { 89 | azure::storage::checksum cs(crc64_val); 90 | CHECK(!cs.is_md5()); 91 | CHECK(cs.is_crc64()); 92 | CHECK(!cs.is_hmac_sha256()); 93 | CHECK(!cs.empty()); 94 | CHECK_UTF8_EQUAL(cs.crc64(), crc64_str); 95 | } 96 | { 97 | azure::storage::checksum cs(azure::storage::checksum_crc64, crc64_val); 98 | CHECK(!cs.is_md5()); 99 | CHECK(cs.is_crc64()); 100 | CHECK(!cs.is_hmac_sha256()); 101 | CHECK(!cs.empty()); 102 | CHECK_UTF8_EQUAL(cs.crc64(), crc64_str); 103 | } 104 | { 105 | azure::storage::checksum cs(azure::storage::checksum_hmac_sha256, hmac_sha256_str); 106 | CHECK(!cs.is_md5()); 107 | CHECK(!cs.is_crc64()); 108 | CHECK(cs.is_hmac_sha256()); 109 | CHECK(!cs.empty()); 110 | CHECK_UTF8_EQUAL(cs.hmac_sha256(), hmac_sha256_str); 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/cloud_file_client_test.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "file_test_base.h" 20 | #include "check_macros.h" 21 | 22 | #pragma region Fixture 23 | 24 | #pragma endregion 25 | 26 | SUITE(File) 27 | { 28 | TEST_FIXTURE(file_service_test_base, get_share_reference) 29 | { 30 | utility::string_t share_name = get_random_share_name(); 31 | azure::storage::cloud_file_share share = m_client.get_share_reference(share_name); 32 | 33 | CHECK(!share.service_client().base_uri().primary_uri().is_empty()); 34 | CHECK(share.service_client().credentials().is_shared_key()); 35 | CHECK(share.name() == share_name); 36 | CHECK(!share.uri().primary_uri().is_empty()); 37 | CHECK(share.metadata().empty()); 38 | CHECK(share.properties().etag().empty()); 39 | CHECK(!share.properties().last_modified().is_initialized()); 40 | CHECK(share.is_valid()); 41 | } 42 | 43 | /// 44 | /// Test list shares with create a number of shares and compare the list share results with created shares. 45 | /// 46 | TEST_FIXTURE(file_service_test_base_with_objects_to_delete, list_shares_with_prefix) 47 | { 48 | auto prefix = get_random_share_name(); 49 | 50 | create_share(prefix, 10); 51 | 52 | auto listing = list_all_shares(prefix, true, 0, azure::storage::file_request_options()); 53 | 54 | check_share_list(listing, prefix, true); 55 | } 56 | 57 | /// 58 | /// Test list shares with create a number of shares and compare the list share results with created shares. 59 | /// 60 | TEST_FIXTURE(file_service_test_base_with_objects_to_delete, list_shares) 61 | { 62 | auto prefix = get_random_share_name(); 63 | 64 | create_share(prefix, 1); 65 | 66 | auto listing = list_all_shares(utility::string_t(), true, 0, azure::storage::file_request_options()); 67 | 68 | check_share_list(listing, prefix, false); 69 | } 70 | 71 | // see in service_properties_test for file service properties test. 72 | 73 | TEST_FIXTURE(file_service_test_base_with_objects_to_delete, list_shares_with_continuation_token) 74 | { 75 | auto prefix = get_random_string(); 76 | create_share(prefix, 10); 77 | 78 | std::vector listing; 79 | azure::storage::continuation_token token; 80 | azure::storage::file_request_options options; 81 | 82 | do { 83 | auto results = m_client.list_shares_segmented(prefix, true, 3, token, options, m_context); 84 | CHECK(results.results().size() <= 3); 85 | 86 | std::copy(results.results().begin(), results.results().end(), std::back_inserter(listing)); 87 | token = results.continuation_token(); 88 | } while (!token.empty()); 89 | 90 | check_share_list(listing, prefix, true); 91 | } 92 | 93 | TEST_FIXTURE(file_service_test_base, file_shared_key_lite) 94 | { 95 | auto client = test_config::instance().account().create_cloud_file_client(); 96 | client.set_authentication_scheme(azure::storage::authentication_scheme::shared_key_lite); 97 | client.list_shares_segmented(utility::string_t(), true, 3, azure::storage::continuation_token(), azure::storage::file_request_options(), m_context); 98 | } 99 | 100 | // see in cloud_storage_account_test for file account sas test. 101 | } -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/file_test_base.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "CurrentTest.h" 22 | 23 | #include "cpprest/filestream.h" 24 | 25 | #include "test_base.h" 26 | #include "was/file.h" 27 | #include "was/blob.h" 28 | 29 | class file_service_test_base : public test_base 30 | { 31 | public: 32 | 33 | file_service_test_base() 34 | : m_client(test_config::instance().account().create_cloud_file_client()) 35 | { 36 | } 37 | 38 | ~file_service_test_base() 39 | { 40 | } 41 | 42 | void check_equal(const azure::storage::cloud_file_share& source, const azure::storage::cloud_file_share& target); 43 | void check_equal(const azure::storage::cloud_file_directory& source, const azure::storage::cloud_file_directory& target); 44 | void check_equal(const azure::storage::cloud_file& source, const azure::storage::cloud_file& target); 45 | 46 | protected: 47 | 48 | static utility::string_t fill_buffer_and_get_md5(std::vector& buffer); 49 | static utility::string_t fill_buffer_and_get_md5(std::vector& buffer, size_t offset, size_t count); 50 | static utility::string_t get_random_share_name(size_t length = 10); 51 | 52 | std::vector list_all_shares(const utility::string_t& prefix, bool get_metadata, int max_results, const azure::storage::file_request_options& options); 53 | 54 | azure::storage::cloud_file_client m_client; 55 | }; 56 | 57 | class file_service_test_base_with_objects_to_delete : public file_service_test_base 58 | { 59 | 60 | public: 61 | 62 | file_service_test_base_with_objects_to_delete() 63 | { 64 | } 65 | 66 | ~file_service_test_base_with_objects_to_delete() 67 | { 68 | for (auto iter = m_shares_to_delete.begin(); iter != m_shares_to_delete.end(); ++iter) 69 | { 70 | try 71 | { 72 | iter->delete_share(); 73 | } 74 | catch (const azure::storage::storage_exception&) 75 | { 76 | } 77 | } 78 | } 79 | 80 | protected: 81 | void create_share(const utility::string_t& prefix, std::size_t num); 82 | void check_share_list(const std::vector& list, const utility::string_t& prefix, bool check_found); 83 | 84 | std::vector m_shares_to_delete; 85 | }; 86 | 87 | class file_share_test_base : public file_service_test_base 88 | { 89 | public: 90 | file_share_test_base() 91 | { 92 | m_share = m_client.get_share_reference(get_random_share_name()); 93 | } 94 | 95 | ~file_share_test_base() 96 | { 97 | try 98 | { 99 | m_share.delete_share(); 100 | } 101 | catch (const azure::storage::storage_exception&) 102 | { 103 | } 104 | } 105 | 106 | void check_access(const utility::string_t& sas_token, uint8_t permissions, const azure::storage::cloud_file_shared_access_headers& headers, const azure::storage::cloud_file& original_file); 107 | 108 | protected: 109 | static utility::string_t get_random_directory_name(size_t length = 10); 110 | 111 | azure::storage::cloud_file_share m_share; 112 | }; 113 | 114 | class file_directory_test_base : public file_share_test_base 115 | { 116 | public: 117 | file_directory_test_base() 118 | { 119 | m_share.create_if_not_exists(); 120 | m_directory = m_share.get_directory_reference(get_random_string()); 121 | } 122 | 123 | ~file_directory_test_base() 124 | { 125 | } 126 | 127 | protected: 128 | static utility::string_t get_random_file_name(size_t length = 10); 129 | 130 | azure::storage::cloud_file_directory m_directory; 131 | }; 132 | 133 | class file_test_base : public file_directory_test_base 134 | { 135 | public: 136 | file_test_base() 137 | { 138 | m_directory.create_if_not_exists(); 139 | m_file = m_directory.get_file_reference(get_random_string()); 140 | } 141 | 142 | ~file_test_base() 143 | { 144 | } 145 | 146 | protected: 147 | 148 | bool wait_for_copy(azure::storage::cloud_file& file); 149 | 150 | azure::storage::cloud_file m_file; 151 | }; 152 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/queue_test_base.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "queue_test_base.h" 20 | #include "check_macros.h" 21 | #include "wascore/streams.h" 22 | 23 | utility::string_t queue_service_test_base::queue_type_name = utility::string_t(_XPLATSTR("queue")); 24 | 25 | azure::storage::cloud_queue_client queue_service_test_base::get_queue_client() 26 | { 27 | return test_config::instance().account().create_cloud_queue_client(); 28 | } 29 | 30 | utility::string_t queue_service_test_base::get_queue_name() 31 | { 32 | return get_object_name(queue_type_name); 33 | } 34 | 35 | azure::storage::cloud_queue queue_service_test_base::get_queue(bool create) 36 | { 37 | azure::storage::cloud_queue_client client = get_queue_client(); 38 | utility::string_t queue_name = get_queue_name(); 39 | azure::storage::cloud_queue queue = client.get_queue_reference(queue_name); 40 | if (create) 41 | { 42 | queue.create_if_not_exists(); 43 | } 44 | return queue; 45 | } 46 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/queue_test_base.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "CurrentTest.h" 22 | 23 | #include "test_base.h" 24 | #include "was/queue.h" 25 | 26 | class queue_service_test_base : public test_base 27 | { 28 | public: 29 | 30 | queue_service_test_base() 31 | { 32 | } 33 | 34 | ~queue_service_test_base() 35 | { 36 | } 37 | 38 | protected: 39 | static utility::string_t queue_type_name; 40 | 41 | static azure::storage::cloud_queue_client get_queue_client(); 42 | static utility::string_t get_queue_name(); 43 | static azure::storage::cloud_queue get_queue(bool create = true); 44 | }; 45 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | // stdafx.cpp : source file that includes just the standard includes 19 | // Microsoft.WindowsAzure.Storage.UnitTests.pch will be the pre-compiled header 20 | // stdafx.obj will contain the pre-compiled type information 21 | 22 | #include "stdafx.h" 23 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/stdafx.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | // stdafx.h : include file for standard system include files, 19 | // or project specific include files that are used frequently, but 20 | // are changed infrequently 21 | // 22 | 23 | #pragma once 24 | 25 | #include "targetver.h" 26 | 27 | // This is required to support enough number of arguments in VC11, especially for std::bind 28 | #define _VARIADIC_MAX 8 29 | 30 | #include "UnitTest++.h" 31 | #include "TestReporterStdout.h" 32 | 33 | #include 34 | #include 35 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/storage_exception_test.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "blob_test_base.h" 20 | #include "table_test_base.h" 21 | #include "check_macros.h" 22 | 23 | SUITE(Core) 24 | { 25 | TEST_FIXTURE(block_blob_test_base, storage_extended_error_verify_xml_with_details) 26 | { 27 | const size_t buffer_size = 8 * 1024; 28 | std::vector buffer; 29 | buffer.resize(buffer_size); 30 | auto md5 = fill_buffer_and_get_md5(buffer); 31 | 32 | auto stream = concurrency::streams::bytestream::open_istream(buffer); 33 | m_blob.upload_block(get_block_id(0), stream, md5); 34 | 35 | try 36 | { 37 | stream.seek(1024, std::ios_base::beg); 38 | m_blob.upload_block(get_block_id(1), stream, md5); 39 | CHECK(false); 40 | } 41 | catch (azure::storage::storage_exception& ex) 42 | { 43 | CHECK_UTF8_EQUAL(_XPLATSTR("Md5Mismatch"), ex.result().extended_error().code()); 44 | CHECK(!ex.result().extended_error().message().empty()); 45 | CHECK(ex.result().extended_error().details().size() > 0); 46 | } 47 | } 48 | 49 | TEST_FIXTURE(table_service_test_base, storage_extended_error_verify_json_with_details) 50 | { 51 | utility::string_t table_name = get_table_name(); 52 | azure::storage::cloud_table_client client = get_table_client(); 53 | azure::storage::cloud_table table = client.get_table_reference(table_name); 54 | 55 | azure::storage::table_request_options options; 56 | azure::storage::operation_context context = m_context; 57 | try 58 | { 59 | table.delete_table(options, context); 60 | CHECK(false); 61 | } 62 | catch (const azure::storage::storage_exception& e) 63 | { 64 | CHECK(e.result().extended_error().code().compare(_XPLATSTR("ResourceNotFound")) == 0); 65 | CHECK(!e.result().extended_error().message().empty()); 66 | } 67 | } 68 | 69 | TEST_FIXTURE(table_service_test_base, storage_extended_error_verify_xml_with_details) 70 | { 71 | utility::string_t table_name = get_table_name(); 72 | azure::storage::cloud_table_client client = get_table_client(); 73 | azure::storage::cloud_table table = client.get_table_reference(table_name); 74 | 75 | azure::storage::table_request_options options; 76 | azure::storage::operation_context context = m_context; 77 | context.set_sending_request([](web::http::http_request &r, azure::storage::operation_context) { 78 | r.headers()[_XPLATSTR("Accept")] = _XPLATSTR("application/xml"); 79 | }); 80 | 81 | try 82 | { 83 | table.exists(options, context); 84 | CHECK(false); 85 | } 86 | catch (const azure::storage::storage_exception& e) 87 | { 88 | CHECK(e.result().extended_error().code().compare(_XPLATSTR("MediaTypeNotSupported")) == 0); 89 | CHECK(!e.result().extended_error().message().empty()); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/table_test_base.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "table_test_base.h" 20 | #include "check_macros.h" 21 | #include "wascore/streams.h" 22 | 23 | utility::string_t table_service_test_base::table_type_name = utility::string_t(_XPLATSTR("table")); 24 | 25 | azure::storage::cloud_table_client table_service_test_base::get_table_client() 26 | { 27 | return test_config::instance().account().create_cloud_table_client(); 28 | } 29 | 30 | utility::string_t table_service_test_base::get_table_name() 31 | { 32 | // table name naming convention: "^[A-Za-z][A-Za-z0-9]{2,62}$" 33 | // here we construct the table name as: 34 | // object_name_prefix + "tableA0" + random_characters 35 | 36 | std::vector charset; 37 | for (utility::char_t c = 'A'; c <= 'Z'; ++c) charset.push_back(c); 38 | for (utility::char_t c = 'a'; c <= 'z'; ++c) charset.push_back(c); 39 | for (utility::char_t c = '0'; c <= '9'; ++c) charset.push_back(c); 40 | 41 | utility::string_t table_name; 42 | table_name.reserve(39U + table_type_name.size()); 43 | table_name.append(object_name_prefix); 44 | table_name.append(table_type_name); 45 | table_name.append(1, _XPLATSTR('A')); 46 | table_name.append(1, _XPLATSTR('0')); 47 | table_name.append(get_random_string(charset, 10)); 48 | 49 | return table_name; 50 | } 51 | 52 | azure::storage::cloud_table table_service_test_base::get_table(bool create) 53 | { 54 | azure::storage::cloud_table_client client = get_table_client(); 55 | utility::string_t table_name = get_table_name(); 56 | azure::storage::cloud_table table = client.get_table_reference(table_name); 57 | if (create) 58 | { 59 | table.create_if_not_exists(); 60 | } 61 | return table; 62 | } -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/table_test_base.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "CurrentTest.h" 22 | 23 | #include "test_base.h" 24 | #include "was/table.h" 25 | 26 | class table_service_test_base : public test_base 27 | { 28 | public: 29 | 30 | table_service_test_base() 31 | { 32 | } 33 | 34 | ~table_service_test_base() 35 | { 36 | } 37 | 38 | protected: 39 | static utility::string_t table_type_name; 40 | 41 | static azure::storage::cloud_table_client get_table_client(); 42 | static utility::string_t get_table_name(); 43 | static azure::storage::cloud_table get_table(bool create = true); 44 | }; 45 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/targetver.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | // Including SDKDDKVer.h defines the highest available Windows platform. 21 | 22 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 23 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 24 | 25 | #ifdef _WIN32 26 | #include 27 | #endif 28 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/test_base.h: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #pragma once 19 | 20 | #include "was/common.h" 21 | #include "was/storage_account.h" 22 | 23 | #if defined(_WIN32) 24 | #define OPERATION_CANCELED "operation canceled" 25 | #else 26 | #define OPERATION_CANCELED "Operation canceled" 27 | #endif 28 | 29 | bool get_random_boolean(); 30 | int32_t get_random_int32(); 31 | int64_t get_random_int64(); 32 | double get_random_double(); 33 | 34 | class test_config 35 | { 36 | public: 37 | 38 | static const test_config& instance() 39 | { 40 | static test_config singleton_instance; 41 | return singleton_instance; 42 | } 43 | 44 | const azure::storage::cloud_storage_account& account() const 45 | { 46 | return m_account; 47 | } 48 | 49 | const azure::storage::cloud_storage_account& premium_account() const 50 | { 51 | return m_premium_account; 52 | } 53 | 54 | const azure::storage::cloud_storage_account& blob_storage_account() const 55 | { 56 | return m_blob_storage_account; 57 | } 58 | 59 | const utility::string_t& get_oauth_account_name() const; 60 | utility::string_t get_oauth_token() const; 61 | 62 | private: 63 | 64 | test_config(); 65 | 66 | azure::storage::cloud_storage_account m_account; 67 | azure::storage::cloud_storage_account m_premium_account; 68 | azure::storage::cloud_storage_account m_blob_storage_account; 69 | 70 | utility::string_t m_token_account_name; 71 | utility::string_t m_token_tenant_id; 72 | utility::string_t m_token_client_id; 73 | utility::string_t m_token_client_secret; 74 | utility::string_t m_token_resource; 75 | }; 76 | 77 | class test_base 78 | { 79 | public: 80 | 81 | test_base() 82 | { 83 | print_client_request_id(m_context, _XPLATSTR("test fixture")); 84 | } 85 | 86 | ~test_base() 87 | { 88 | } 89 | 90 | protected: 91 | 92 | static void print_client_request_id(const azure::storage::operation_context& context, const utility::string_t& purpose); 93 | static void check_parallelism(const azure::storage::operation_context& context, int expected_parallelism); 94 | 95 | azure::storage::operation_context m_context; 96 | 97 | static utility::string_t object_name_prefix; 98 | 99 | public: 100 | 101 | static utility::datetime parse_datetime(const utility::string_t& value, utility::datetime::date_format format = utility::datetime::date_format::RFC_1123); 102 | static utility::string_t get_string(utility::char_t value1, utility::char_t value2); 103 | static utility::string_t get_random_string(const std::vector& charset, size_t size); 104 | static utility::string_t get_random_string(size_t size = 10); 105 | static utility::datetime get_random_datetime(); 106 | static std::vector get_random_binary_data(); 107 | static void fill_buffer(std::vector& buffer); 108 | static void fill_buffer(std::vector& buffer, size_t offset, size_t count); 109 | static utility::uuid get_random_guid(); 110 | static utility::string_t get_object_name(const utility::string_t& object_type_name); 111 | 112 | template 113 | static TEnum get_random_enum(TEnum max_enum_value) 114 | { 115 | return static_cast(get_random_int32() % (static_cast(max_enum_value) + 1)); 116 | } 117 | 118 | template 119 | static std::vector transform_if(It it, std::function func_if, std::function func_tran) 120 | { 121 | std::vector results; 122 | It end_it; 123 | while (it != end_it) 124 | { 125 | if (func_if(*it)) 126 | { 127 | results.push_back(func_tran(*it)); 128 | } 129 | ++it; 130 | } 131 | return results; 132 | } 133 | }; 134 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/test_configurations.json: -------------------------------------------------------------------------------- 1 | { 2 | "target": "production", 3 | "premium_target": "premium_account", 4 | "blob_storage_target": "blob_storage_account", 5 | "tenants": [ 6 | { 7 | "name": "devstore", 8 | "type": "devstore", 9 | "connection_string": "UseDevelopmentStorage=true" 10 | }, 11 | { 12 | "name": "production", 13 | "type": "cloud", 14 | "connection_string": "DefaultEndpointsProtocol=https;" 15 | }, 16 | { 17 | "name": "premium_account", 18 | "type": "cloud", 19 | "connection_string": "DefaultEndpointsProtocol=https;" 20 | }, 21 | { 22 | "name": "blob_storage_account", 23 | "type": "cloud", 24 | "connection_string": "DefaultEndpointsProtocol=https;" 25 | } 26 | ], 27 | "token_information": { 28 | "account_name": "", 29 | "tenant_id": "", 30 | "client_id": "", 31 | "client_secret": "", 32 | "resource": "https://storage.azure.com" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/timer_handler_test.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2018 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "check_macros.h" 20 | #include "test_base.h" 21 | 22 | #include "wascore/timer_handler.h" 23 | 24 | SUITE(Core) 25 | { 26 | TEST_FIXTURE(test_base, cancellation_token_source_multiple_cancel_test) 27 | { 28 | std::string exception_msg; 29 | try 30 | { 31 | pplx::cancellation_token_source source; 32 | for (auto i = 0; i < 100; ++i) 33 | { 34 | source.cancel(); 35 | } 36 | } 37 | catch (std::exception& e) 38 | { 39 | exception_msg = e.what(); 40 | } 41 | 42 | CHECK_EQUAL("", exception_msg); 43 | } 44 | 45 | TEST_FIXTURE(test_base, cancellation_token_source_multiple_cancel_concurrent_test) 46 | { 47 | std::string exception_msg; 48 | try 49 | { 50 | for (auto i = 0; i < 5000; ++i) 51 | { 52 | pplx::cancellation_token_source source; 53 | pplx::task_completion_event tce; 54 | std::vector> tasks; 55 | for (auto k = 0; k < 100; ++k) 56 | { 57 | auto task = pplx::create_task(tce).then([source]() { source.cancel(); }); 58 | tasks.push_back(task); 59 | } 60 | tce.set(); 61 | for (auto k = 0; k < 100; ++k) 62 | { 63 | tasks[k].get(); 64 | } 65 | } 66 | } 67 | catch (std::exception& e) 68 | { 69 | exception_msg = e.what(); 70 | } 71 | 72 | CHECK_EQUAL("", exception_msg); 73 | } 74 | } -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/tests/unicode_test.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2013 Microsoft Corporation 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // ----------------------------------------------------------------------------------------- 17 | 18 | #include "stdafx.h" 19 | #include "check_macros.h" 20 | #include "blob_test_base.h" 21 | #include "queue_test_base.h" 22 | #include "table_test_base.h" 23 | 24 | const std::string error_invalid_characters_in_resource_name("The specifed resource name contains invalid characters."); 25 | const std::string error_bad_request("Bad Request"); 26 | 27 | SUITE(Core) 28 | { 29 | TEST_FIXTURE(container_test_base, container_name_unicode) 30 | { 31 | auto container = m_client.get_container_reference(_XPLATSTR("容器1")); 32 | CHECK_STORAGE_EXCEPTION(container.exists(), error_invalid_characters_in_resource_name); 33 | CHECK_STORAGE_EXCEPTION(container.create_if_not_exists(), error_invalid_characters_in_resource_name); 34 | } 35 | 36 | TEST_FIXTURE(blob_test_base, directory_name_unicode) 37 | { 38 | utility::string_t dir_name(_XPLATSTR("目录1")); 39 | utility::string_t blob_name(_XPLATSTR("block_blob")); 40 | auto dir = m_container.get_directory_reference(dir_name); 41 | auto blob = dir.get_block_blob_reference(blob_name); 42 | blob.upload_text(_XPLATSTR("test")); 43 | CHECK(blob.exists()); 44 | CHECK(blob.name() == dir_name + _XPLATSTR("/") + blob_name); 45 | } 46 | 47 | TEST_FIXTURE(blob_test_base, blob_name_unicode) 48 | { 49 | utility::string_t blob_name(_XPLATSTR("文件1")); 50 | auto blob = m_container.get_block_blob_reference(blob_name); 51 | blob.upload_text(_XPLATSTR("test2")); 52 | CHECK(blob.exists()); 53 | CHECK(blob.name() == blob_name); 54 | } 55 | 56 | TEST_FIXTURE(queue_service_test_base, queue_name_unicode) 57 | { 58 | utility::string_t queue_name(_XPLATSTR("队列1")); 59 | azure::storage::cloud_queue_client client = get_queue_client(); 60 | azure::storage::cloud_queue queue = client.get_queue_reference(queue_name); 61 | CHECK_STORAGE_EXCEPTION(queue.exists(), error_invalid_characters_in_resource_name); 62 | CHECK_STORAGE_EXCEPTION(queue.create(), error_invalid_characters_in_resource_name); 63 | } 64 | 65 | TEST_FIXTURE(table_service_test_base, table_name_unicode) 66 | { 67 | utility::string_t table_name(_XPLATSTR("表格1")); 68 | azure::storage::cloud_table_client client = get_table_client(); 69 | azure::storage::cloud_table table = client.get_table_reference(table_name); 70 | CHECK(false == table.exists()); 71 | CHECK_STORAGE_EXCEPTION(table.create(), error_bad_request); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Microsoft.WindowsAzure.Storage/version.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-storage-cpp/00bb3704fec59445247a6dac983f611e0dd18e8a/Microsoft.WindowsAzure.Storage/version.rc -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | 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/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | 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://aka.ms/opensource/security/msrc). 18 | 19 | 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: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | 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://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | - dev 4 | 5 | pr: 6 | - dev 7 | 8 | variables: 9 | cpp_rest_sdk_version: 2.10.16 10 | 11 | jobs: 12 | - job: build_test_linux 13 | displayName: Build and Test on Linux 14 | timeoutInMinutes: 240 15 | 16 | strategy: 17 | maxParallel: 16 18 | matrix: 19 | UBUNTU1404: 20 | container_image: ubuntu14.04:cpprestsdk_$(cpp_rest_sdk_version) 21 | build_type: Release 22 | UBUNTU1604: 23 | container_image: ubuntu16.04:cpprestsdk_$(cpp_rest_sdk_version) 24 | build_type: Release 25 | UBUNTU1804: 26 | container_image: ubuntu18.04:cpprestsdk_$(cpp_rest_sdk_version) 27 | build_type: Release 28 | UBUNTU1804_DEBUG: 29 | container_image: ubuntu18.04:cpprestsdk_$(cpp_rest_sdk_version) 30 | build_type: Debug 31 | UBUNTU1804_I686: 32 | container_image: ubuntu18.04.i686:cpprestsdk_$(cpp_rest_sdk_version) 33 | build_type: Release 34 | build_env_init: export CXXFLAGS=-m32 35 | CENTOS7_DEBUG: 36 | container_image: centos7:cpprestsdk_$(cpp_rest_sdk_version) 37 | build_type: Debug 38 | build_env_init: source scl_source enable devtoolset-4 39 | 40 | pool: 41 | vmImage: 'ubuntu-16.04' 42 | 43 | container: 44 | image: azurecppsdkpipeline.azurecr.io/$(container_image) 45 | endpoint: azure_docker_registry_connection 46 | 47 | steps: 48 | - script: | 49 | $(build_env_init) 50 | cmake Microsoft.WindowsAzure.Storage/CMakeLists.txt -B$(Build.BinariesDirectory) -DCMAKE_BUILD_TYPE=$(build_type) -DBUILD_SAMPLES=ON -DBUILD_TESTS=ON 51 | cmake --build $(Build.BinariesDirectory) -- -j$(nproc) 52 | displayName: Build 53 | 54 | - script: echo ${MAPPED_TEST_CONFIGURATION} > $(Build.BinariesDirectory)/Binaries/test_configurations.json 55 | displayName: Copy Test Configuration 56 | env: 57 | MAPPED_TEST_CONFIGURATION: $(test_configuration) 58 | 59 | - script: ./azurestoragetest $(excluded_testcases) $(retry_policy) --warning-message='##vso[task.logissue type=warning]' 60 | workingDirectory: $(Build.BinariesDirectory)/Binaries 61 | displayName: Run Tests 62 | 63 | 64 | - job: build_test_windows 65 | displayName: Build and Test on Windows 66 | timeoutInMinutes: 300 67 | 68 | variables: 69 | - name: project_file 70 | value: Microsoft.WindowsAzure.Storage\tests\Microsoft.WindowsAzure.Storage.UnitTests.v141.vcxproj 71 | 72 | strategy: 73 | maxParallel: 16 74 | matrix: 75 | VS2017: 76 | vm_image: vs2017-win2016 77 | platform: x64 78 | configuration: Release 79 | toolset: v141 80 | VS2017_DEBUG: 81 | vm_image: vs2017-win2016 82 | platform: x64 83 | configuration: Debug 84 | toolset: v141 85 | VS2017_WIN32: 86 | vm_image: vs2017-win2016 87 | platform: Win32 88 | configuration: Release 89 | toolset: v141 90 | VS2019: 91 | vm_image: windows-2019 92 | platform: x64 93 | configuration: Release 94 | toolset: v142 95 | 96 | pool: 97 | vmImage: $(vm_image) 98 | 99 | steps: 100 | - powershell: | 101 | Invoke-WebRequest -Uri https://codeload.github.com/microsoft/vcpkg/zip/master -OutFile vcpkg-master.zip 102 | Add-Type -AssemblyName System.IO.Compression.FileSystem 103 | [System.IO.Compression.ZipFile]::ExtractToDirectory("vcpkg-master.zip", "C:\") 104 | cd C:\vcpkg-master 105 | .\bootstrap-vcpkg.bat 106 | .\vcpkg install cpprestsdk[core]:x86-windows cpprestsdk[core]:x64-windows unittest-cpp:x86-windows unittest-cpp:x64-windows 107 | .\vcpkg integrate install 108 | displayName: Install Dependencies 109 | 110 | - task: MSBUILD@1 111 | displayName: Build 112 | inputs: 113 | solution: $(project_file) 114 | msbuildArguments: /p:OutDir=$(Build.BinariesDirectory)\ /p:PlatformToolset=$(toolset) 115 | platform: $(platform) 116 | configuration: $(configuration) 117 | 118 | - script: echo %MAPPED_TEST_CONFIGURATION% > $(Build.BinariesDirectory)\test_configurations.json 119 | displayName: Copy Test Configuration 120 | env: 121 | MAPPED_TEST_CONFIGURATION: $(test_configuration) 122 | 123 | - script: wastoretest.exe $(excluded_testcases) $(retry_policy) --warning-message="##vso[task.logissue type=warning]" 124 | workingDirectory: $(Build.BinariesDirectory) 125 | displayName: Run Tests 126 | -------------------------------------------------------------------------------- /build.proj: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Configuration=Debug;Platform=Win32 9 | 10 | 11 | Configuration=Release;Platform=Win32 12 | 13 | 14 | Configuration=Debug;Platform=x64 15 | 16 | 17 | Configuration=Release;Platform=x64 18 | 19 | 20 | 21 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /build.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.539 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.WindowsAzure.Storage.v140", "Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.v140.vcxproj", "{25D342C3-6CDA-44DD-A16A-32A19B692785}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.WindowsAzure.Storage.v141", "Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.v141.vcxproj", "{A8E200A6-910E-44F4-9E8E-C37E45B7AD42}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|Win32.Build.0 = Debug|Win32 20 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x64.ActiveCfg = Debug|x64 21 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Debug|x64.Build.0 = Debug|x64 22 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|Win32.ActiveCfg = Release|Win32 23 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|Win32.Build.0 = Release|Win32 24 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x64.ActiveCfg = Release|x64 25 | {25D342C3-6CDA-44DD-A16A-32A19B692785}.Release|x64.Build.0 = Release|x64 26 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Debug|Win32.Build.0 = Debug|Win32 28 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Debug|x64.ActiveCfg = Debug|x64 29 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Debug|x64.Build.0 = Debug|x64 30 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Release|Win32.ActiveCfg = Release|Win32 31 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Release|Win32.Build.0 = Release|Win32 32 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Release|x64.ActiveCfg = Release|x64 33 | {A8E200A6-910E-44F4-9E8E-C37E45B7AD42}.Release|x64.Build.0 = Release|x64 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {35737520-7450-46BF-A029-F05E072DBE40} 40 | EndGlobalSection 41 | EndGlobal 42 | --------------------------------------------------------------------------------