# database

## Description

This example demonstrates how you can create a managed database using an Azure SQL database and provide a virtual machine access to it.

## Concepts

The following concepts are present in this example:

* Databases
* Virtual Machines

## Venues

This example is regularly tested against:

![azure](https://4172935707-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAzdR4AyersVibQD8Ei%2Fsync%2Fd2a51335bb50c250c191db68d5c884bf9b32ca84.png?generation=1596016310017287\&alt=media)

## Release Notes

### 1.0

* Initial release.

## Blueprint

```yaml
---
variables:
  admin_username:
    description: >-
      The VM administrative account username to use for SSH access.
    type: string
    default: adminuser
  admin_public_key:
    description: >-
      The OpenSSH Public Key used to protect access to the randomly generated
      Administrative password on AWS.  This is ignored on Azure.
      This is an issue we are aware of and plan to resolve.
    type: string
  db_username:
    description: >-
      The SQL host database administrative account username. Used to create and
      connect to the SQL infrastructure.
    type: string
    default: adminuser
  db_password:
    description: >-
      The SQL host database administrative account password. Used to create and
      connect to the SQL infrastructure.
    type: string

location:
  region:
    my-region:
      country: USA
      area: west
  folder:
    tuono-managed-database:
      region: my-region

networking:
  network:
    example:
      range: 10.0.0.0/16
      scope: public
  subnet:
    frontend:
      range: 10.0.0.0/24
      network: example
      firewall: allow-ssh-inbound
      scope: public
    backend:
      range: 10.0.100.0/24
      network: example
      scope: isolated
  protocol:
    mssql:
      ports:
        - port: 1433
          proto: tcp
          description: MSSQL
        - port: 11000-11999
          description: Necessary for MSSQL redirect
    ssh:
      ports:
        - port: 22
          proto: tcp
  firewall:
    allow-ssh-inbound:
      rules:
        - protocols: ssh
          to: self

compute:
  image:
    bionic:
      publisher: Canonical
      product: UbuntuServer
      sku: 18.04-LTS
  vm:
    consumer:
      cores: 1
      memory: 3 GB
      image: bionic
      nics:
        external:
          ips:
            - private:
                type: dynamic
              public:
                type: static
          subnet: frontend
          firewall: allow-ssh-inbound
        internal:
          ips:
            - private:
                type: dynamic
          subnet: backend
          firewall: allow-ssh-inbound
          consumes: finance
      tags:
        wicked: awesome
      configure:
        admin:
          username: (( admin_username ))
          public_key: (( admin_public_key ))

managed:
  database:
    finance:
      provides: networking.protocol.mssql
      venue:
        azure:
          type: sql-server
          username: (( db_username ))
          password: (( db_password ))
          database: test-db
```
