Skip to content

Commit

Permalink
Install CCF on AzureVM (#4502)
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-p-smith authored Nov 10, 2022
1 parent 77586e2 commit d85c1dd
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and performant applications that focus on multi-party compute and data.

- Read the [CCF overview](https://ccf.microsoft.com/) and get familiar with [CCF's core concepts](https://microsoft.github.io/CCF/main/overview/what_is_ccf.html)
- [Install](https://microsoft.github.io/CCF/main/build_apps/install_bin.html) CCF on Linux
- Quickly build and run the [sample CCF application](https://github.com/microsoft/ccf-app-template)
- Get familiar with CCF core developer API with the [template CCF app](https://github.com/microsoft/ccf-app-template)
- Quickly build and run [sample CCF apps](https://github.com/microsoft/ccf-app-samples)
- [Build new CCF applications](https://microsoft.github.io/CCF/main/build_apps/index.html) in TypeScript/JavaScript or C++

## Contribute
Expand Down
9 changes: 9 additions & 0 deletions doc/build_apps/install_bin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ From Source
-----------

To build and install CCF from source, please see :doc:`/contribute/build_ccf`.

In Azure
--------

CCF can be installed on an Azure Virtual Machine by running a single script;

.. code-block:: bash
<ccf_path>/getting_started/azure_vm/install_ccf_on_azure_vm.sh
6 changes: 6 additions & 0 deletions getting_started/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Running CCF on a virtual machine

This folder contains two separate ways of setting up a development environment for CCF itself and apps.

1. [azure_vm](./azure_vm/README.md) provides an opinionated way of creating a Virtual Machine on Azure and install CCF for you by cloud-init.
2. `setup_vm` assumes that a bare environment is already available (VM or container) and provides Ansible scripts to setup the development environment by either cloning this repository or installing the CCF Debian package
15 changes: 15 additions & 0 deletions getting_started/azure_vm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Creating a Virtual Machine in Azure to run CCF

This guide is here to give you the bare minimum to get started with CCF. It will walk you through the steps to create a virtual machine in Azure and install CCF on it.

## Prerequisites

You must run this from a bash terminal that you have already logged in to Azure with. If you have not done this, please follow the instructions [here](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest).

## Create a Virtual Machine

Run the following script :

```bash
./getting_started/azure_vm/install_ccf_on_azure_vm.sh
```
42 changes: 42 additions & 0 deletions getting_started/azure_vm/ccf-cloudinit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#cloud-config
package_update: true
package_upgrade: true
apt:
sources:
docker.list:
source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable
keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88

packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- docker-ce
- docker-ce-cli
- containerd.io
- git
- jq

# Enable ipv4 forwarding, required on CIS hardened machines
write_files:
- path: /etc/sysctl.d/enabled_ipv4_forwarding.conf
content: |
net.ipv4.conf.all.forwarding=1
# create the docker group
groups:
- docker

# Add default auto created user to docker group
system_info:
default_user:
groups: [docker]

runcmd:
- cd /home/azureuser && git clone https://github.com/microsoft/CCF.git ccf-install -b release/2.x
- sudo -u azureuser /home/azureuser/ccf-install/getting_started/setup_vm/run.sh /home/azureuser/ccf-install/getting_started/setup_vm/app-run.yml
- export CCF_VERSION=$(curl -ILs -o /dev/null -w %{url_effective} https://github.com/microsoft/CCF/releases/latest | sed 's/^.*ccf-//')
- wget https://github.com/microsoft/CCF/releases/download/ccf-${CCF_VERSION}/ccf_${CCF_VERSION}_amd64.deb
- apt install /home/azureuser/ccf_${CCF_VERSION}_amd64.deb -y
38 changes: 38 additions & 0 deletions getting_started/azure_vm/install_ccf_on_azure_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.

# !!! These are defaults and you can change these if you wish !!!
resourceGroup=rg_ccf_demo
vm_name=ccfdemo
location=westeurope
# This is the smallest VM, you may wish to change this.
vm_size=Standard_DC1s_v2
vnetName=ccf
subnetName=nodes
vnetAddressPrefix=10.0.0.0/16
ccfAddressPrefix=10.0.0.0/24

az group create --name $resourceGroup --location $location

az network vnet create \
--name $vnetName \
--resource-group $resourceGroup \
--address-prefixes $vnetAddressPrefix \
--subnet-name $subnetName \
--subnet-prefixes $ccfAddressPrefix

# Automatically generates a ssh key if one is not present
# https://learn.microsoft.com/en-us/azure/virtual-machines/linux/create-ssh-keys-detailed#generate-keys-automatically-during-deployment
az vm create \
--resource-group $resourceGroup \
--name $vm_name \
--image canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202210180 \
--vnet-name $vnetName \
--subnet $subnetName \
--size $vm_size \
--public-ip-sku Standard \
--admin-username azureuser \
--custom-data ccf-cloudinit.yml \
--generate-ssh-keys \
--output json

0 comments on commit d85c1dd

Please sign in to comment.