Skip to content

Commit

Permalink
restructure + README
Browse files Browse the repository at this point in the history
  • Loading branch information
jpicht committed Mar 11, 2022
1 parent 8f56717 commit 193bcc2
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# simple azure blob tools
This is a collection of very simple tools to manipulate blobs in azure blob storage. Most functions of the azure blob store aren't available through these tools.

## Motivation
I created these tools out of the pain and frustration that comes with trying to work with the tools currently available (looking at you, [azure cli](https://github.com/Azure/azure-cli) and [azcopy](https://github.com/Azure/azure-storage-azcopy)).

For most usecases `azure cli` is absolutely over-powered and the official docker container weighs in at a whopping 1,13GiB (at time of writing).

`azcopy` is a go tool, that has a lot of good functionality. The interface is a bit clunky (anyone else who needed some time to wrap their head around `--from-to`? Still not sure what half of the possible values do), but the deal breaker for me are the [intentional](https://github.com/Azure/azure-storage-azcopy/issues/186) lack of SharedKey and SAS authentication and the choice to use the **kernel keyring**, which is **disabled in docker** by default, or the **gnome-session-keyring**, also not available in docker, to store the session token. Without any option to use *anything* else.

## Usage
List files with prefix
```bash
azls https://<account>.blob.core.windows.net/<container>/<prefix>
```

Output blob contents to STDOUT
```bash
azcat https://<account>.blob.core.windows.net/<container>/<blob>
```

Write blob contents from STDIN
```bash
mongodump --archive | azput https://<account>.blob.core.windows.net/<container>/<blob>
```

Remove blob
```bash
azrm https://<account>.blob.core.windows.net/<container>/<blob>
```

## Authentication
Currently authentication will always be automatically derived from the environment. The environment variables are conveniently named just like the `azure cli` expects.

Supported methods (are tried in this order):
1. connection string `AZURE_STORAGE_CONNECTION_STRING`
1. shared key via `AZURE_STORAGE_ACCOUNT_NAME` and `AZURE_STORAGE_ACCOUNT_KEY`
1. metadata service `169.254.169.254`

## Installation
There are no releases (yet), so the easiest way is installing using go install:

```
go install github.com/jpicht/azcat/cmd/multi/...
```

This will install the four standalone tools `azcat`, `azls`, `azput` and `azrm` into
your `$GOPATH/bin/` directory.

There is a fifth tool called `azblob` which can be used in scenarios where more than one function is needed, but saving on size is necessary. It can either be used directly, but the command line options are a bit clunky and subject to change, or four symlinks (
`azcat`, `azls`, `azput` and `azrm`) can be created pointing to it, and it behaves (nearly) exactly like these tools.
11 changes: 11 additions & 0 deletions cmd/azblob/guess.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ func getExplicitMode() azcat.Mode {
}

func guessMode(blobUrl azblob.BlobURLParts, serviceClient *azblob.ServiceClient) azcat.Mode {
switch os.Args[0] {
case "azls":
return azcat.EMode.List()
case "azcat":
return azcat.EMode.Read()
case "azput":
return azcat.EMode.Write()
case "azrm":
return azcat.EMode.Remove()
}

if blobUrl.BlobName == "/" || blobUrl.BlobName == "" {
return azcat.EMode.List()
}
Expand Down
1 change: 1 addition & 0 deletions cmd/multi/azcat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
azcat
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 193bcc2

Please sign in to comment.