| 1 | # Giovanni |
| 2 | An alternative Azure Storage SDK for Go |
| 3 | |
| 4 | --- |
| 5 | |
| 6 | This repository is an alternative Azure Storage SDK for Go; which supports for: |
| 7 | |
| 8 | - The [Blob Storage APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api) |
| 9 | - The [DataLakeStorage Gen2 APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/data-lake-storage-gen2) |
| 10 | - The [File Storage APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/file-service-rest-api) |
| 11 | - The [Queue Storage APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api) |
| 12 | - The [Table Storage APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/table-service-rest-api) |
| 13 | |
| 14 | At this time we support the following API Versions: |
| 15 | |
| 16 | * `2020-08-04` (`./storage/2020-08-04`) |
| 17 | * `2019-12-12` (`./storage/2019-12-12`) |
| 18 | * `2018-11-09` (`./storage/2018-11-09`) |
| 19 | * `2018-03-28` (`./storage/2018-03-28`) |
| 20 | * `2017-07-29` (`./storage/2017-07-29`) |
| 21 | |
| 22 | We're also open to supporting other versions of the Azure Storage SDK as necessary. |
| 23 | |
| 24 | Documentation for how to use each SDK can be found within the README for that SDK version - for example [here's the README for 2020-08-04](storage/2020-08-04/README.md). |
| 25 | |
| 26 | Each Package also contains Unit and Acceptance tests to ensure that the functionality works; instructions on how to run the tests can be found below. |
| 27 | |
| 28 | ## Mission Statement |
| 29 | |
| 30 | Fundamentally: developers should be able to pick which version of the Azure API they target using this SDK. |
| 31 | |
| 32 | As such, there's two main goals here: |
| 33 | |
| 34 | * New API Versions will be added additively to the `storage` folder. |
| 35 | |
| 36 | * Any supported API Versions will continue to exist in the `storage` folder until they're EOL'd/stop working. |
| 37 | |
| 38 | To ensure that each of these scenarios is possible - we have Acceptance and Unit Tests to confirm that the functionality in these versions works - and will use SemVer as appropriate. |
| 39 | |
| 40 | ## Future Enhancements |
| 41 | |
| 42 | At this time this SDK is mostly feature complete, with a couple of notable additions (since we didn't need them). |
| 43 | |
| 44 | Whilst it's possible to create Snapshots (for example, of a Container) - at this time most SDK calls don't support specifying the optional query-string value for `snapshot`. |
| 45 | |
| 46 | In addition, we also don't support the `timeout` querystring on every API call; this is because instead all SDK methods take a `context` object, which allows a timeout to be set (albeit on the Client rather than the Remote API Call). |
| 47 | |
| 48 | In both instances this is because we didn't need this functionality for our use-cases - but feel free to send a PR if you need this. |
| 49 | |
| 50 | ## Licence |
| 51 | |
| 52 | Apache 2.0 |
| 53 | |
| 54 | ## Technical Implementation |
| 55 | |
| 56 | This SDK makes use of the standard Preparer-Sender-Responder pattern found in [Azure/go-autorest](https://github.com/Azure/go-autorest) - which means that this SDK should be familiar and compatible with [the Azure SDK for Go](https://github.com/Azure/azure-sdk-for-go). |
| 57 | |
| 58 | Depending on the API Version / API being used - different authentication mechanisms are possible (see the README within the specific SDK for more info ([example](XXX)). In all cases one of the following Authorizers will be required: |
| 59 | |
| 60 | * An Authorizer for Azure Active Directory |
| 61 | * A SharedKeyLite Authorizer (for Blob, Queue and Table Storage) |
| 62 | * A SharedKeyLite Authorizer (for Table Storage) |
| 63 | |
| 64 | Examples for all of these can be found below in [the Examples Directory](examples/). |
| 65 | |
| 66 | There's a [Pull Request open adding both a SharedKey and a SharedKeyLite authorizer to Azure/go-autorest](http://github.com/Azure/go-autorest/pull/416) |
| 67 | |
| 68 | ## Running the Tests |
| 69 | |
| 70 | Each package contains both Unit and Acceptance Tests which provision a real Storage Account on Azure, and then run tests against that. |
| 71 | |
| 72 | To run those, the following Environment Variables need to be set: |
| 73 | |
| 74 | * `ARM_TENANT_ID` - The ID of the Tenant where tests should be run, such as `00000000-0000-0000-0000-000000000000`. |
| 75 | * `ARM_SUBSCRIPTION_ID` - The ID of the Subscription where tests should be run, such as `00000000-0000-0000-0000-000000000000`. |
| 76 | * `ARM_CLIENT_ID` - The ID of the AzureAD Application (also known as a Client ID), such as `00000000-0000-0000-0000-000000000000`. |
| 77 | * `ARM_CLIENT_SECRET` - The Client Secret/Password for a Service Principal where tests should be run. |
| 78 | * `ARM_ENVIRONMENT` - The name of the Azure Environment where the tests should be run, such as `Public` or `Germany`. |
| 79 | * `ARM_TEST_LOCATION` - The name of the Azure Region where resources provisioned by the tests should be created, such as `West Europe`. |
| 80 | * `ACCTEST` - confirms that you want the tests to be run, set this to any value. |
| 81 | |
| 82 | Once those Environment Variables are set - you should be able to run: |
| 83 | |
| 84 | ```bash |
| 85 | $ ACCTEST=1 go test -v ./storage/... |
| 86 | ``` |
| 87 | |
| 88 | You can also run them for a specific API version by running: |
| 89 | |
| 90 | ```bash |
| 91 | $ ACCTEST=1 go test -v ./storage/2020-08-04/... |
| 92 | ``` |
| 93 | |
| 94 | ## Debugging |
| 95 | |
| 96 | You can see the Requests/Responses from this SDK by setting the Environment Variable `TEST_LOG` to any value. |