Skip to content

Commit

Permalink
Merge pull request #133 from NeowayLabs/addAzureTools
Browse files Browse the repository at this point in the history
Add azure tools on image
  • Loading branch information
katcipis authored Jul 7, 2017
2 parents 68a3543 + 0a4b5a8 commit 38c65f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ FROM neowaylabs/klbdeps:0.2

COPY ./aws ${NASHPATH}/lib/klb/aws
COPY ./azure ${NASHPATH}/lib/klb/azure

COPY ./tools/azure/createsp.sh ${NASHPATH}/bin/azure-createsp.sh
COPY ./tools/azure/getcredentials.sh ${NASHPATH}/bin/azure-getcredentials.sh

ENV PATH $PATH:${NASHPATH}/bin
6 changes: 2 additions & 4 deletions docs/Azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ setenv AZURE_CLIENT_ID="XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXX"
setenv AZURE_CLIENT_SECRET="123456"
```

Redirect the output above to a file and import into your nash session:
Copy the environment variables from the output to a file and import into your nash session:

```sh
λ> ./tools/azure/getcredentials.sh nash <subscription name> <service principal name> <service secret> > credentials
λ> import ./credentials
```

Expand All @@ -88,10 +87,9 @@ export AZURE_CLIENT_ID="XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXX"
export AZURE_CLIENT_SECRET="123456"
```

Redirect the output above to a file and import into your lame shell session:
Write the output above to a file and import into your lame shell session:

```sh
λ> ./tools/azure/getcredentials.sh sh <subscription name> <service principal name> <service secret> > credentials
λ> source ./credentials
```

Expand Down
18 changes: 12 additions & 6 deletions tools/azure/getcredentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ AZURE_SUBSCRIPTION_NAME = $ARGS[2]
SPNAME = $ARGS[3]
SPSECRET = $ARGS[4]

azure account set $AZURE_SUBSCRIPTION_NAME > /dev/null
azure login
azure account set $AZURE_SUBSCRIPTION_NAME

AZURE_SUBSCRIPTION_ID <= (
azure account show
Expand All @@ -40,16 +41,21 @@ AZURE_TENANT_ID <= (
tr -d "\n"
)

printvar("AZURE_SUBSCRIPTION_ID", $AZURE_SUBSCRIPTION_ID)
printvar("AZURE_SUBSCRIPTION_NAME", $AZURE_SUBSCRIPTION_NAME)
printvar("AZURE_TENANT_ID", $AZURE_TENANT_ID)

AZURE_CLIENT_ID <= (
AZURE_CLIENT_ID <= (
azure ad sp show -c $SPNAME --json |
jq -r ".[0].appId" |
tr -d "\n"
)

echo
echo "environment variables (copy them to a file):"
echo

printvar("AZURE_SUBSCRIPTION_ID", $AZURE_SUBSCRIPTION_ID)
printvar("AZURE_SUBSCRIPTION_NAME", $AZURE_SUBSCRIPTION_NAME)
printvar("AZURE_TENANT_ID", $AZURE_TENANT_ID)
printvar("AZURE_CLIENT_ID", $AZURE_CLIENT_ID)
printvar("AZURE_CLIENT_SECRET", $SPSECRET)
printvar("AZURE_SERVICE_PRINCIPAL", "http://"+$SPNAME)

echo

0 comments on commit 38c65f4

Please sign in to comment.