Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from Azure-Samples/dev
Browse files Browse the repository at this point in the history
initial sample commit
  • Loading branch information
daviddesberg authored May 21, 2018
2 parents 4c82fd1 + 140a263 commit a733914
Show file tree
Hide file tree
Showing 8 changed files with 5,831 additions and 74 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ bower_components
# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
# Typescript v1 declaration files
typings/

# Optional npm cache directory
Expand All @@ -57,5 +57,3 @@ typings/
# dotenv environment variables file
.env

# next.js build output
.next
13 changes: 0 additions & 13 deletions CHANGELOG.md

This file was deleted.

140 changes: 83 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,83 @@
# Project Name

(short, 1-3 sentenced, description of the project)

## Features

This project framework provides the following features:

* Feature 1
* Feature 2
* ...

## Getting Started

### Prerequisites

(ideally very short, if any)

- OS
- Library version
- ...

### Installation

(ideally very short)

- npm install [package name]
- mvn install
- ...

### Quickstart
(Add steps to get up and running quickly)

1. git clone [repository clone url]
2. cd [respository name]
3. ...


## Demo

A demo app is included to show how to use the project.

To run the demo, follow these steps:

(Add steps to start up the demo)

1.
2.
3.

## Resources

(Any additional resources or related projects)

- Link to supporting information
- Link to similar sample
- ...
---
services: key-vault
platforms: nodejs
author: lusitanian
---

# Managed Azure Storage Account Keys for Azure Key Vault using the Azure Node SDK

This sample repo includes sample code demonstrating common mechanisms for managing storage account keys using Key Vault.

## Prerequisites
* node.js 8+
* An Azure Service Principal for running the sample on your Azure account. You can create an Azure service principal using one of the following guides:
- [Azure CLI](https://azure.microsoft.com/documentation/articles/resource-group-authenticate-service-principal-cli/),
- [PowerShell](https://azure.microsoft.com/documentation/articles/resource-group-authenticate-service-principal/)
- [Azure Portal](https://azure.microsoft.com/documentation/articles/resource-group-create-service-principal-portal/).


## Quickstart
1. If you don't have it, install [node.js](https://nodejs.org)
2. Set the following environment variables using the information from your service principal.
```
export AZURE_SUBSCRIPTION_ID={your subscription id}
export AZURE_CLIENT_ID={your client id}
export AZURE_CLIENT_SECRET={your client secret}
export AZURE_TENANT_ID={your tenant id as a GUID}
export AZURE_CLIENT_OID={Object id of the service principal}
```
> On Windows, use `set` instead of `export`.
3. Clone the repo, install node packages, and run.
```
git clone https://github.com/Azure-Samples/key-vault-node-storage-accounts.git key-vault
cd key-vault
npm install
node storage_account_sample.js
```

### Note ###
Certain portions of this sample require authenticated user to execute. For this reason the sample will prompt the user to authenticate with a device code. For more details see in-line comments in storage_acount_sample.js


## What does this sample do?
The storage account sample is broken down into 8 different methods called in sequence by the `main()` method in `storage_account_sample.js`:
```
async function main() {
console.log('Azure Key Vault - Managed Storage Account Key Sample');
// Get or create our sample vault
const vault = await SampleUtil.getSampleVault();
// Create and add a storage account to our sample vault
const storageAccount = await addStorageAccount(vault);
// Demonstrate updating properties of the managed storage account
await updateStorageAccount(storageAccount, vault);
// Demonstrate regeneration of a storage account key
await regenerateStorageAccountKey(storageAccount, vault);
// Demonstrate listing off the storage accounts in the vault
await getStorageAccounts(vault);
// Demonstrate the creation of an account-level SAS definition
await createAccountSASDefinition(storageAccount, vault);
// Demonstrate the creation of a container-level SAS definition
await createBlobSASDefinition(storageAccount, vault);
// List all SAS definitions in the account
await getSASDefinitions(storageAccount, vault);
// Finally, remove the storage account from the vault
await deleteStorageAccount(vault, storageAccount);
}
```
## References and further reading

- [Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node)
- [Azure KeyVault Documentation](https://azure.microsoft.com/en-us/documentation/services/key-vault/)
- [Key Vault REST API Reference](https://msdn.microsoft.com/en-us/library/azure/dn903609.aspx)
- [Manage Key Vault using CLI](https://azure.microsoft.com/en-us/documentation/articles/key-vault-manage-with-cli/)
- [Storing and using secrets in Azure](https://blogs.msdn.microsoft.com/dotnet/2016/10/03/storing-and-using-secrets-in-azure/)
Loading

0 comments on commit a733914

Please sign in to comment.