From cad69e1a8ce78ca3a42dbf45bb92b652d4763599 Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Thu, 2 Jun 2022 12:49:32 -0700 Subject: [PATCH] Remove samples with docker.io (#3621) * remove samples using docker.io * removing docker files * remove project --- .devcontainer/Dockerfile | 78 ----------------- .devcontainer/devcontainer.json | 32 ------- CMakeLists.txt | 1 - Dockerfile | 79 ------------------ Dockerfile.src | 15 ---- .../vcpkg-keyvault/.devcontainer/Dockerfile | 7 -- .../.devcontainer/devcontainer.json | 20 ----- .../integration/vcpkg-keyvault/CMakeLists.txt | 30 ------- samples/integration/vcpkg-keyvault/LICENSE | 21 ----- samples/integration/vcpkg-keyvault/README.md | 67 --------------- .../integration/vcpkg-keyvault/src/main.cpp | 83 ------------------- .../vcpkg-storage/.devcontainer/Dockerfile | 14 ---- .../.devcontainer/devcontainer.json | 20 ----- .../integration/vcpkg-storage/CMakeLists.txt | 32 ------- samples/integration/vcpkg-storage/LICENSE | 21 ----- samples/integration/vcpkg-storage/README.md | 67 --------------- .../integration/vcpkg-storage/src/main.cpp | 69 --------------- 17 files changed, 656 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 Dockerfile delete mode 100644 Dockerfile.src delete mode 100644 samples/integration/vcpkg-keyvault/.devcontainer/Dockerfile delete mode 100644 samples/integration/vcpkg-keyvault/.devcontainer/devcontainer.json delete mode 100644 samples/integration/vcpkg-keyvault/CMakeLists.txt delete mode 100644 samples/integration/vcpkg-keyvault/LICENSE delete mode 100644 samples/integration/vcpkg-keyvault/README.md delete mode 100644 samples/integration/vcpkg-keyvault/src/main.cpp delete mode 100644 samples/integration/vcpkg-storage/.devcontainer/Dockerfile delete mode 100644 samples/integration/vcpkg-storage/.devcontainer/devcontainer.json delete mode 100644 samples/integration/vcpkg-storage/CMakeLists.txt delete mode 100644 samples/integration/vcpkg-storage/LICENSE delete mode 100644 samples/integration/vcpkg-storage/README.md delete mode 100644 samples/integration/vcpkg-storage/src/main.cpp diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 222779e5af..0000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,78 +0,0 @@ -FROM debian:10 - -# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, -# this user's GID/UID must match your local user UID/GID to avoid permission issues -# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See -# https://aka.ms/vscode-remote/containers/non-root-user for details. -ARG USERNAME=azure-sdk-for-cpp -ARG USER_UID=1000 -ARG USER_GID=$USER_UID -ARG PORT=4000 - -# Install packages as root -USER root - -# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. -RUN apt-get update \ - && export DEBIAN_FRONTEND=noninteractive \ - && LANG=C LC_ALL=C apt-get -y install --no-install-recommends \ - apt-utils \ - dialog \ - sudo \ - # - # Install vim, git, process tools, lsb-release - git \ - openssh-client \ - less \ - # - # Azure SDK for C++ dev env - make \ - cmake \ - ninja-build \ - build-essential \ - zlib1g-dev \ - libcurl4-openssl-dev \ - libssl-dev \ - libxml2-dev \ - gdb \ - # clang format 10 req - gnupg2 \ - wget \ - ca-certificates \ - # vcpkg reqs - curl \ - zip \ - unzip \ - tar \ - pkg-config \ - - # - # Add en_US.UTF-8 locale - && echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen \ - && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ - && echo 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' | tee -a /etc/apt/sources.list \ - && echo 'deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' | tee -a /etc/apt/sources.list \ - && apt-get update \ - && apt-get -y install --no-install-recommends clang-format-10 \ - # - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # - # Add sudo support for the non-root user - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - # - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -RUN cd / \ - && git clone https://github.com/microsoft/vcpkg.git \ - && cd vcpkg \ - && ./bootstrap-vcpkg.sh \ - && ./vcpkg install curl - -# Switch back to the non-root user -USER ${USERNAME} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dbfa1099a5..0000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "Ubuntu-20.04.VCPKG", - "dockerFile": "Dockerfile", - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": [ - "ms-vscode.cpptools-themes", - "bbenoist.doxygen", - "streetsidesoftware.code-spell-checker", - "ms-vscode.cpptools", - "xaver.clang-format", - "twxs.cmake", - "ms-vscode.cmake-tools", - "eamodio.gitlens", - "davidschuldenfrei.gtest-adapter" - ], - // Do not run as root. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "azure-sdk-for-cpp", - "containerEnv": { - "AZURE_CLIENT_ID": "", - "AZURE_CLIENT_SECRET": "", - "AZURE_KEYVAULT_HSM_URL": "", - "AZURE_KEYVAULT_URL": "", - "AZURE_LOG_LEVEL": "1", - "AZURE_TENANT_ID": "", - "AZURE_TEST_MODE": "PLAYBACK", - "CLIENT_OBJECTID": "", - // set or unset to run using vcpkg or not - "VCPKG_ROOT": "/vcpkg" - } -} diff --git a/CMakeLists.txt b/CMakeLists.txt index 391c771aa9..8b8ff1fa3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,5 @@ add_subdirectory(sdk/storage) add_subdirectory(sdk/template) if(BUILD_SAMPLES) - add_subdirectory(samples/integration/vcpkg-keyvault) add_subdirectory(samples/integration/vcpkg-all-smoke) endif() diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2152112551..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -FROM debian:10 - -# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, -# this user's GID/UID must match your local user UID/GID to avoid permission issues -# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See -# https://aka.ms/vscode-remote/containers/non-root-user for details. -ARG USERNAME=azure-sdk-for-cpp -ARG USER_UID=1000 -ARG USER_GID=$USER_UID -ARG PORT=4000 - -# Install packages as root -USER root - -# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. -RUN apt-get update \ - && export DEBIAN_FRONTEND=noninteractive \ - && LANG=C LC_ALL=C apt-get -y install --no-install-recommends \ - apt-utils \ - dialog \ - sudo \ - # - # Install vim, git, process tools, lsb-release - git \ - openssh-client \ - less \ - # - # Azure SDK for C++ dev env - make \ - #cmake \ - ninja-build \ - build-essential \ - zlib1g-dev \ - libcurl4-openssl-dev \ - libssl-dev \ - libxml2-dev \ - gdb \ - # clang format 10 req - gnupg2 \ - wget \ - ca-certificates \ - # vcpkg reqs - curl \ - zip \ - unzip \ - tar \ - pkg-config \ - - # - # Add en_US.UTF-8 locale - && echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen \ - && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ - && echo 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' | tee -a /etc/apt/sources.list \ - && echo 'deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' | tee -a /etc/apt/sources.list \ - && apt-get update \ - && apt-get -y install --no-install-recommends clang-format-10 \ - # - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # - # Add sudo support for the non-root user - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - # - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -RUN wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz \ - && tar -zxvf cmake-3.20.2.tar.gz \ - && cd cmake-3.20.2 \ - && ./bootstrap \ - && make \ - && make install - -# Switch back to the non-root user -USER ${USERNAME} diff --git a/Dockerfile.src b/Dockerfile.src deleted file mode 100644 index 7db38f2cdd..0000000000 --- a/Dockerfile.src +++ /dev/null @@ -1,15 +0,0 @@ -FROM base:latest -ARG USERNAME=azure-sdk-for-cpp -# Install packages as root -USER root - -WORKDIR /home/azure-sdk-for-cpp/src - -COPY ./sdk/keyvault/azure-security-keyvault-certificates ./sdk/keyvault/azure-security-keyvault-certificates -COPY ./sdk/keyvault/azure-security-keyvault-shared ./sdk/keyvault/azure-security-keyvault-shared -COPY ./cmake-modules ./cmake-modules - -WORKDIR /home/azure-sdk-for-cpp/src/sdk/keyvault/azure-security-keyvault-certificates - -USER ${USERNAME} - diff --git a/samples/integration/vcpkg-keyvault/.devcontainer/Dockerfile b/samples/integration/vcpkg-keyvault/.devcontainer/Dockerfile deleted file mode 100644 index e5f5ca09ab..0000000000 --- a/samples/integration/vcpkg-keyvault/.devcontainer/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -# base image installs keyvault beta1 from vcpkg only -FROM vhvb1989/keyvault:beta1 - -RUN cd vcpkg \ - && sudo ./vcpkg install azure-identity-cpp - -ENV VCPKG_DEFAULT_TRIPLET=x64-linux diff --git a/samples/integration/vcpkg-keyvault/.devcontainer/devcontainer.json b/samples/integration/vcpkg-keyvault/.devcontainer/devcontainer.json deleted file mode 100644 index 0dd126a6d8..0000000000 --- a/samples/integration/vcpkg-keyvault/.devcontainer/devcontainer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "Ubuntu-21.04", - "dockerFile": "Dockerfile", - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": [ - "ms-vscode.cpptools-themes", - "bbenoist.doxygen", - "streetsidesoftware.code-spell-checker", - "ms-vscode.cpptools", - "xaver.clang-format", - "twxs.cmake", - "ms-vscode.cmake-tools", - "eamodio.gitlens", - "davidschuldenfrei.gtest-adapter" - ], - // Do not run as root. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "azure-sdk-for-cpp" -} diff --git a/samples/integration/vcpkg-keyvault/CMakeLists.txt b/samples/integration/vcpkg-keyvault/CMakeLists.txt deleted file mode 100644 index 1707c6a2c7..0000000000 --- a/samples/integration/vcpkg-keyvault/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# SPDX-License-Identifier: MIT - -# vcpkg integration. -if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - CACHE STRING "") -endif() -if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) - set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") -endif() - -# Project set up -cmake_minimum_required(VERSION 3.13) -project(Application-using-keyvault-from-vcpkg LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED True) - -add_executable ( - application - src/main -) - -# Link to Azure SDK -target_link_libraries(application - PRIVATE - Azure::azure-security-keyvault-keys - Azure::azure-identity - get-env-helper -) diff --git a/samples/integration/vcpkg-keyvault/LICENSE b/samples/integration/vcpkg-keyvault/LICENSE deleted file mode 100644 index 51b6a76e54..0000000000 --- a/samples/integration/vcpkg-keyvault/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. diff --git a/samples/integration/vcpkg-keyvault/README.md b/samples/integration/vcpkg-keyvault/README.md deleted file mode 100644 index dd7e4b7054..0000000000 --- a/samples/integration/vcpkg-keyvault/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Integrating the Azure SDK for C++ into your application using vcpkg - -This application shows how to integrate the Azure SDK for C++ in your application. It uses vcpkg to acquire and build the Azure SDK for C++ client libraries. Your CMake project needs to link the libraries from vcpkg by setting the toolchain file to vcpkg (shown below). - -## Pre-requisites - -There are two options to set up the development environment: - -### Manual installation - -Install the [Azure SDK for C++ dependencies](https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md#third-party-dependencies). - -- CMake project (min version 3.13). -- C++ version 14 or greater. - -### Container - -The sample provides a .devcontainer folder which can be used by VS Code to build and run a docker container with the required C++ build tools and with vcpkg installed. - -This method requires VS Code + [Remote Container](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) to be installed in the system. Also make sure to have Docker installed and running. This method works for any operating system where Docker and VSCode is supported like Windows, Linux and macOS. The development environment will be Debian 10. - -- Open vcpkg folder in VS Code. -- VS Code will detect the `devcontainer` configuration and ask you if you would like to re-open the folder in a container. Click Yes. -- If VS Code did not ask, you can press F1 and type `Reopen in container` option. - -Once VS Code builds and run the container, open the terminal and continue to build step. - -> Note: The container is set up to automatically link vcpkg to CMake projects by setting env variables that the CMake sample project will use to set the toolchain. - -## Build - -### Linux terminal - -```bash -# -# Building the application. -# Instructions from application root directory. -# - -# Create build directory just the first time. -mkdir build -cd build - -# Generate and build -# This code assumes that the SDK dependencies were installed with vcpkg -# When using docker provided container, the TOOLCHAIN option is not required (cmake ..). -cmake -DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/scripts/buildsystems/vcpkg.cmake .. -cmake -build . -``` - -### Windows VS - -If you are using Visual Studio, the toolchain to link vcpkg is set with `CMakeSettings.json`. Update this file and set the vcpkg toolchain file for vcpkg (VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake). After setting the toolchain, VS can generate and build the sample. Use VS to open the sample folder only. - -## Run application - -Review source code header for `environment variables` that must be set up before running the app. - -```bash -# -# Running the Application -# Instructions from inside the build directory. -# - -# Run binary (.exe on Windows) -./application -``` diff --git a/samples/integration/vcpkg-keyvault/src/main.cpp b/samples/integration/vcpkg-keyvault/src/main.cpp deleted file mode 100644 index 541a95160c..0000000000 --- a/samples/integration/vcpkg-keyvault/src/main.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -/** - * @brief This sample provides the code implementation to use the Key Vault SDK client for C++ - * to create, get, update, delete and purge a key. - * - * @remark The following environment variables must be set before running the sample. - * - AZURE_KEYVAULT_URL: To the Key Vault account URL. - * - AZURE_TENANT_ID: Tenant ID for the Azure account. - * - AZURE_CLIENT_ID: The Client ID to authenticate the request. - * - AZURE_CLIENT_SECRET: The client secret. - * - */ - -#include "get_env.hpp" - -#include -#include -#include - -#include -#include -#include -#include - -using namespace Azure::Security::KeyVault::Keys; - -int main() -{ - auto tenantId = std::getenv("AZURE_TENANT_ID"); - auto clientId = std::getenv("AZURE_CLIENT_ID"); - auto clientSecret = std::getenv("AZURE_CLIENT_SECRET"); - auto credential - = std::make_shared(tenantId, clientId, clientSecret); - - KeyClient keyClient(std::getenv("AZURE_KEYVAULT_URL"), credential); - - std::string rsaKeyName("CloudRsaKey" + Azure::Core::Uuid::CreateUuid().ToString()); - try - { - auto rsaKey = CreateRsaKeyOptions(rsaKeyName); - rsaKey.KeySize = 2048; - rsaKey.ExpiresOn = std::chrono::system_clock::now() + std::chrono::hours(24 * 365); - - keyClient.CreateRsaKey(rsaKey); - - KeyVaultKey cloudRsaKey = keyClient.GetKey(rsaKeyName).Value; - std::cout << "Key is returned with name " << cloudRsaKey.Name() << " and type " - << cloudRsaKey.GetKeyType().ToString() << std::endl; - - cloudRsaKey.Properties.ExpiresOn - = cloudRsaKey.Properties.ExpiresOn.Value() + std::chrono::hours(24 * 365); - KeyVaultKey updatedKey = keyClient.UpdateKeyProperties(cloudRsaKey.Properties).Value; - std::cout << "Key's updated expiry time is " << updatedKey.Properties.ExpiresOn->ToString() - << std::endl; - - CreateRsaKeyOptions newRsaKey(rsaKeyName); - newRsaKey.KeySize = 4096; - newRsaKey.ExpiresOn = std::chrono::system_clock::now() + std::chrono::hours(24 * 365); - - keyClient.CreateRsaKey(newRsaKey); - - DeleteKeyOperation operation = keyClient.StartDeleteKey(rsaKeyName); - - // You only need to wait for completion if you want to purge or recover the key. - operation.PollUntilDone(std::chrono::milliseconds(2000)); - - keyClient.PurgeDeletedKey(rsaKeyName); - } - catch (Azure::Core::Credentials::AuthenticationException const& e) - { - std::cout << "Authentication Exception happened:" << std::endl << e.what() << std::endl; - return 1; - } - catch (Azure::Core::RequestFailedException const& e) - { - std::cout << "KeyVault Client Exception happened:" << std::endl << e.Message << std::endl; - return 1; - } - - return 0; -} diff --git a/samples/integration/vcpkg-storage/.devcontainer/Dockerfile b/samples/integration/vcpkg-storage/.devcontainer/Dockerfile deleted file mode 100644 index 2bac8b8507..0000000000 --- a/samples/integration/vcpkg-storage/.devcontainer/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# base image installs dev env for storage v12 beta10 -FROM vhvb1989/storage12:preview10 - -# Get vcpkg and install storage blobs -RUN sudo git clone https://github.com/microsoft/vcpkg.git \ - && cd vcpkg \ - # VCPKG commit version for key vault keys 1.0.0-beta.1 - Storage beta 10 - Identity beta 5 - Core beta 8 - && sudo git checkout 414bec05f2a97cfc0ddb8e22fd4635dfe2a20ab8 \ - && sudo ./bootstrap-vcpkg.sh - -ENV VCPKG_ROOT=/vcpkg - -RUN cd vcpkg \ - && sudo ./vcpkg install azure-storage-blobs-cpp diff --git a/samples/integration/vcpkg-storage/.devcontainer/devcontainer.json b/samples/integration/vcpkg-storage/.devcontainer/devcontainer.json deleted file mode 100644 index a1a73de699..0000000000 --- a/samples/integration/vcpkg-storage/.devcontainer/devcontainer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "AzureSDK-Storage-v12-beta10", - "dockerFile": "Dockerfile", - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": [ - "ms-vscode.cpptools-themes", - "bbenoist.doxygen", - "streetsidesoftware.code-spell-checker", - "ms-vscode.cpptools", - "xaver.clang-format", - "twxs.cmake", - "ms-vscode.cmake-tools", - "eamodio.gitlens", - "davidschuldenfrei.gtest-adapter" - ], - // Do not run as root. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "azure-sdk-for-cpp" -} diff --git a/samples/integration/vcpkg-storage/CMakeLists.txt b/samples/integration/vcpkg-storage/CMakeLists.txt deleted file mode 100644 index c6ca69c645..0000000000 --- a/samples/integration/vcpkg-storage/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# SPDX-License-Identifier: MIT - -# vcpkg integration. -if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - CACHE STRING "") -endif() -if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) - set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") -endif() - -# Project set up -cmake_minimum_required(VERSION 3.13) -project(Application-using-storage-blobs-from-vcpkg LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED True) - -find_package(CURL REQUIRED) -find_package(azure-storage-blobs-cpp CONFIG REQUIRED) - -add_executable ( - application - src/main -) - -# Link to Azure SDK -target_link_libraries(application - PRIVATE - Azure::azure-storage-blobs - get-env-helper -) diff --git a/samples/integration/vcpkg-storage/LICENSE b/samples/integration/vcpkg-storage/LICENSE deleted file mode 100644 index 51b6a76e54..0000000000 --- a/samples/integration/vcpkg-storage/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. diff --git a/samples/integration/vcpkg-storage/README.md b/samples/integration/vcpkg-storage/README.md deleted file mode 100644 index a1c4e78988..0000000000 --- a/samples/integration/vcpkg-storage/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Integrating the Azure SDK for C++ into your application using vcpkg - -This application shows how to integrate the Azure SDK for C++ in your application. It uses vcpkg to adquire and build the Azure SDK for C++ client libraries. Your CMake project needs to link the libraries from vcpkg by setting the toolchain file to vcpkg (shown below). - -## Pre-requisites - -There are two options to set up the development environment: - -### Manual installation - -Install the [Azure SDK for C++ dependencies](https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md#third-party-dependencies). - -- CMake project (min version 3.13). -- C++ version 14 or greater. - -### Container - -The sample provides a .devcontainer folder which can be used by VS Code to build and run a docker container with the required C++ build tools and with vcpkg installed. - -This method requires VS Code + [Remote Container](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) to be installed in the system. Also make sure to have Docker installed and running. This method works for any operating system where Docker and VS Code is supported like Windows, Linux and macOS. The development environment will be Debian 10. - -- Open vcpkg folder in VS Code. -- VS Code will detect the `devcontainer` configuration and ask you if you would like to re-open the folder in a container. Click Yes. -- If VS Code did not ask, you can press F1 and type `Reopen in container` option. - -Once VS Code builds and run the container, open the terminal and continue to build step. - -> Note: The container is set up to automatically link vcpkg to CMake projects by setting env variables that the CMake sample project will use to set the toolchain. - -## Build - -### Linux terminal - -```bash -# -# Building the application. -# Instructions from application root directory. -# - -# Create build directory just the first time. -mkdir build -cd build - -# Generate and build -# This code assumes that the SDK dependencies were installed with vcpkg -# When using docker provided container, the TOOLCHAIN option is not required (cmake ..). -cmake -DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/scripts/buildsystems/vcpkg.cmake .. -cmake -build . -``` - -### Windows VS - -If you are using Visual Studio, the toolchain to link vcpkg is set with `CMakeSettings.json`. Upate this file and set the vcpkg toolchain file for vcpkg (VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake). After setting the toolchain, VS can generate and build the sample. Use VS to open the sample folder only. - -## Run application - -Review source code header for `environment variables` that must be set up before running the app. - -```bash -# -# Running the Application -# Instructions from inside the build directory. -# - -# Run binary (.exe on Windows) -./application -``` diff --git a/samples/integration/vcpkg-storage/src/main.cpp b/samples/integration/vcpkg-storage/src/main.cpp deleted file mode 100644 index 7d7f873a89..0000000000 --- a/samples/integration/vcpkg-storage/src/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -/** - * @brief This sample provides the code implementation to use the Storage blobs SDK client for C++ - * to create a container and upload a blob to it. - * - * @remark The following environment variables must be set before running the sample. - * - AZURE_STORAGE_CONNECTION_STRING: Set it Azure Storage connection string. - * - */ - -#include "get_env.hpp" - -#include - -#include - -const std::string& GetConnectionString(); - -int main() -{ - using namespace Azure::Storage::Blobs; - - std::string containerName = "sample-container"; - std::string blobName = "sample-blob"; - std::string blobContent = "Hello Azure!"; - - auto containerClient - = BlobContainerClient::CreateFromConnectionString(GetConnectionString(), containerName); - - containerClient.CreateIfNotExists(); - - BlockBlobClient blobClient = containerClient.GetBlockBlobClient(blobName); - - blobClient.UploadFrom(reinterpret_cast(blobContent.data()), blobContent.size()); - - Azure::Storage::Metadata blobMetadata = {{"key1", "value1"}, {"key2", "value2"}}; - blobClient.SetMetadata(blobMetadata); - - auto properties = blobClient.GetProperties().Value; - for (auto metadata : properties.Metadata) - { - std::cout << metadata.first << ":" << metadata.second << std::endl; - } - blobContent.resize(static_cast(properties.BlobSize)); - - blobClient.DownloadTo(reinterpret_cast(&blobContent[0]), blobContent.size()); - - std::cout << blobContent << std::endl; - - return 0; -} - -const std::string& GetConnectionString() -{ - const static std::string ConnectionString = ""; - - if (!ConnectionString.empty()) - { - return ConnectionString; - } - const static std::string envConnectionString = std::getenv("AZURE_STORAGE_CONNECTION_STRING"); - if (!envConnectionString.empty()) - { - return envConnectionString; - } - throw std::runtime_error("Cannot find connection string"); -}