Skip to content

Commit 3a0b242

Browse files
authored
Merge pull request MicrosoftDocs#27013 from jluk/master
remove preview tags for GA and include terraform walkthrough
2 parents be85569 + dd6364e commit 3a0b242

13 files changed

+237
-42
lines changed

articles/cloud-shell/TOC.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
## [Persisting storage in PowerShell](persisting-shell-storage-powershell.md)
1515
## [Using the window](using-the-shell-window.md)
1616

17+
# Examples
18+
## [Deploy Azure resources with Terraform in Bash](example-terraform-bash.md)
19+
1720
# [Pricing](pricing.md)
1821

1922
# [Troubleshooting](troubleshooting.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
---
2+
title: Deploy with Terraform with Bash in Azure Cloud Shell | Microsoft Docs
3+
description: Deploy Azure resources with Terraform in Bash
4+
services: Azure
5+
documentationcenter: ''
6+
author: jluk
7+
manager: timlt
8+
tags: azure-cloud-shell
9+
10+
ms.service: azure
11+
ms.workload: infrastructure-services
12+
ms.tgt_pltfrm: vm-linux
13+
ms.devlang: na
14+
ms.topic: article
15+
ms.date: 11/13/2017
16+
ms.author: juluk
17+
---
18+
19+
# Terraform and Bash in Cloud Shell
20+
This article walks you through creating a resource group with the [Terraform AzureRM provider](https://www.terraform.io/docs/providers/azurerm/index.html).
21+
22+
[Hashicorp Terraform](https://www.terraform.io/) is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members to be edited, reviewed, and versioned. The Microsoft AzureRM provider is used to interact with resources supported by Azure Resource Manager via the AzureRM APIs.
23+
24+
## Automatic authentication
25+
Terraform is installed in Bash in Cloud Shell by default. Additionally, Cloud Shell automatically authenticates your default Azure CLI 2.0 subscription to deploy resources through the Terraform Azure modules.
26+
27+
Terraform uses the default Azure CLI 2.0 subscription that is set. To update default subscriptions, run:
28+
29+
```azurecli-interactive
30+
az account set --subscription mySubscriptionName
31+
```
32+
33+
## Walkthrough
34+
### Launch Bash in Cloud Shell
35+
1. Launch Cloud Shell from your preferred location
36+
2. Verify your preferred subscription is set
37+
38+
```azurecli-interactive
39+
az account show
40+
```
41+
42+
### Create a Terraform template
43+
Create a new Terraform template named main.tf with your preferred text editor.
44+
45+
```
46+
vim main.tf
47+
```
48+
49+
Copy/paste the following code into Cloud Shell.
50+
51+
```
52+
resource "azurerm_resource_group" "myterraformgroup" {
53+
name = "myRgName"
54+
location = "West US"
55+
}
56+
```
57+
58+
Save your file and exit your text editor.
59+
60+
### Terraform init
61+
Begin by running `terraform init`.
62+
63+
```
64+
justin@Azure:~$ terraform init
65+
66+
Initializing provider plugins...
67+
68+
The following providers do not have any version constraints in configuration,
69+
so the latest version was installed.
70+
71+
To prevent automatic upgrades to new major versions that may contain breaking
72+
changes, it is recommended to add version = "..." constraints to the
73+
corresponding provider blocks in configuration, with the constraint strings
74+
suggested below.
75+
76+
* provider.azurerm: version = "~> 0.2"
77+
78+
Terraform has been successfully initialized!
79+
80+
You may now begin working with Terraform. Try running "terraform plan" to see
81+
any changes that are required for your infrastructure. All Terraform commands
82+
should now work.
83+
84+
If you ever set or change modules or backend configuration for Terraform,
85+
rerun this command to reinitialize your working directory. If you forget, other
86+
commands will detect it and remind you to do so if necessary.
87+
```
88+
89+
The [terraform init command](https://www.terraform.io/docs/commands/init.html) is used to initialize a working directory containing Terraform configuration files. The `terraform init` command is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. It is safe to run this command multiple times.
90+
91+
### Terraform plan
92+
Preview the resources to be created by the Terraform template with `terraform plan`.
93+
94+
```
95+
justin@Azure:~$ terraform plan
96+
Refreshing Terraform state in-memory prior to plan...
97+
The refreshed state will be used to calculate this plan, but will not be
98+
persisted to local or remote state storage.
99+
100+
101+
------------------------------------------------------------------------
102+
103+
An execution plan has been generated and is shown below.
104+
Resource actions are indicated with the following symbols:
105+
+ create
106+
107+
Terraform will perform the following actions:
108+
109+
+ azurerm_resource_group.demo
110+
id: <computed>
111+
location: "westus"
112+
name: "myRGName"
113+
tags.%: <computed>
114+
115+
116+
Plan: 1 to add, 0 to change, 0 to destroy.
117+
118+
------------------------------------------------------------------------
119+
120+
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
121+
can't guarantee that exactly these actions will be performed if
122+
"terraform apply" is subsequently run.
123+
```
124+
125+
The [terraform plan command](https://www.terraform.io/docs/commands/plan.html) is used to create an execution plan. Terraform performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files. The plan can be saved using -out, and then provided to terraform apply to ensure only the pre-planned actions are executed.
126+
127+
### Terraform apply
128+
Provision the Azure resources with `terraform apply`.
129+
130+
```
131+
justin@Azure:~$ terraform apply
132+
azurerm_resource_group.demo: Creating...
133+
location: "" => "westus"
134+
name: "" => "myRGName"
135+
tags.%: "" => "<computed>"
136+
azurerm_resource_group.demo: Creation complete after 0s (ID: /subscriptions/mySubIDmysub/resourceGroups/myRGName)
137+
138+
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
139+
```
140+
141+
The [terraform apply command](https://www.terraform.io/docs/commands/apply.html) is used to apply the changes required to reach the desired state of the configuration.
142+
143+
### Verify deployment with Azure CLI 2.0
144+
Run `az group show -n myRgName` to verify the resource has succeeded provisioning.
145+
146+
```azcliinteractive
147+
az group show -n myRgName
148+
```
149+
150+
### Clean up with terraform destroy
151+
Clean up the resource group created with the [Terraform destroy command](https://www.terraform.io/docs/commands/destroy.html) to clean up Terraform-created infrastructure.
152+
153+
```
154+
justin@Azure:~$ terraform destroy
155+
azurerm_resource_group.demo: Refreshing state... (ID: /subscriptions/mySubID/resourceGroups/myRGName)
156+
157+
An execution plan has been generated and is shown below.
158+
Resource actions are indicated with the following symbols:
159+
- destroy
160+
161+
Terraform will perform the following actions:
162+
163+
- azurerm_resource_group.demo
164+
165+
166+
Plan: 0 to add, 0 to change, 1 to destroy.
167+
168+
Do you really want to destroy?
169+
Terraform will destroy all your managed infrastructure, as shown above.
170+
There is no undo. Only 'yes' will be accepted to confirm.
171+
172+
Enter a value: yes
173+
174+
azurerm_resource_group.demo: Destroying... (ID: /subscriptions/mySubID/resourceGroups/myRGName)
175+
azurerm_resource_group.demo: Still destroying... (ID: /subscriptions/mySubID/resourceGroups/myRGName, 10s elapsed)
176+
azurerm_resource_group.demo: Still destroying... (ID: /subscriptions/mySubID/resourceGroups/myRGName, 20s elapsed)
177+
azurerm_resource_group.demo: Still destroying... (ID: /subscriptions/mySubID/resourceGroups/myRGName, 30s elapsed)
178+
azurerm_resource_group.demo: Still destroying... (ID: /subscriptions/mySubID/resourceGroups/myRGName, 40s elapsed)
179+
azurerm_resource_group.demo: Destruction complete after 45s
180+
181+
Destroy complete! Resources: 1 destroyed.
182+
```
183+
184+
You have successfully created an Azure resource through Terraform. Visit next steps to continue learning about Cloud Shell.
185+
186+
## Next steps
187+
[Learn about the Terraform Azure provider](https://www.terraform.io/docs/providers/azurerm/#)<br>
188+
[Bash in Cloud Shell quickstart](quickstart.md)

articles/cloud-shell/features-powershell.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ ms.date: 10/25/2017
1717
ms.author: damaerte
1818
---
1919

20-
# Features & tools for PowerShell in Azure Cloud Shell
20+
# Features & tools for PowerShell in Azure Cloud Shell (Preview)
2121

2222
[!include [features-introblock](../../includes/cloud-shell-features-introblock.md)]
2323

2424
> [!TIP]
2525
> Features & tools for [Bash](features.md) is also available.
2626
27-
PowerShell in Cloud Shell runs on `Windows Server 2016`.
27+
PowerShell in Cloud Shell (Preview) runs on `Windows Server 2016`.
2828

2929
## Features
3030

3131
### Secure automatic authentication
3232

33-
PowerShell in Cloud Shell securely and automatically authenticates account access for the Azure PowerShell.
33+
PowerShell in Cloud Shell (Preview) securely and automatically authenticates account access for the Azure PowerShell.
3434

3535
### Files persistence across sessions
3636

@@ -42,7 +42,7 @@ Since each request for Cloud Shell is allocating a temporary machine, files outs
4242

4343
### Azure drive (Azure:)
4444

45-
PowerShell in Cloud Shell starts you in Azure drive (`Azure:`).
45+
PowerShell in Cloud Shell (Preview) starts you in Azure drive (`Azure:`).
4646
Azure drive enables easy discovery and navigation of Azure resources such as Compute, Network, Storage etc. similar to filesystem navigation.
4747
You can continue to use the familiar [Azure PowerShell cmdlets](https://docs.microsoft.com/en-us/powershell/azure) to manage these resources.
4848
Any changes made to the Azure resources, either made directly in Azure portal or through Azure PowerShell cmdlets, are instantly reflected in the Azure drive.
@@ -106,6 +106,6 @@ These commands are built on top of PowerShell remoting and require PowerShell co
106106

107107
## Next steps
108108

109-
[Quickstart with PowerShell in Cloud Shell](quickstart-powershell.md)
109+
[Quickstart with PowerShell in Cloud Shell (Preview)](quickstart-powershell.md)
110110

111111
[Learn about Azure PowerShell](https://docs.microsoft.com/powershell/azure/)

articles/cloud-shell/features.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Bash in Azure Cloud Shell (Preview) features | Microsoft Docs
2+
title: Bash in Azure Cloud Shell features | Microsoft Docs
33
description: Overview of features of Bash in Azure Cloud Shell
44
services: Azure
55
documentationcenter: ''

articles/cloud-shell/limitations.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Azure Cloud Shell (Preview) limitations | Microsoft Docs
2+
title: Azure Cloud Shell limitations | Microsoft Docs
33
description: Overview of limitations of Azure Cloud Shell
44
services: azure
55
documentationcenter: ''
@@ -67,7 +67,7 @@ Your history of bash commands may be inconsistent because of Cloud Shell session
6767

6868
### Slow startup time
6969

70-
PowerShell in Azure Cloud Shell could take up to 60 seconds to initialize during preview.
70+
PowerShell in Azure Cloud Shell (Preview) could take up to 60 seconds to initialize during preview.
7171

7272
### No $Home directory persistence
7373

articles/cloud-shell/overview.md

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Azure Cloud Shell (Preview) overview | Microsoft Docs
2+
title: Azure Cloud Shell overview | Microsoft Docs
33
description: Overview of the Azure Cloud Shell.
44
services:
55
documentationcenter: ''
@@ -13,10 +13,10 @@ ms.workload: infrastructure-services
1313
ms.tgt_pltfrm: vm-linux
1414
ms.devlang: na
1515
ms.topic: article
16-
ms.date: 11/02/2017
16+
ms.date: 11/13/2017
1717
ms.author: juluk
1818
---
19-
# Overview of Azure Cloud Shell (Preview)
19+
# Overview of Azure Cloud Shell
2020
Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources.
2121
It gives you the flexibility of choosing the shell experience that best suits the way you work.
2222
Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.
@@ -29,7 +29,7 @@ Leverage Bash or PowerShell from the shell selector dropdown:
2929

3030
![Bash in Cloud Shell](media/overview/overview-bash-pic.png)
3131

32-
![PowerShell in Cloud Shell](media/overview/overview-ps-pic.png)
32+
![PowerShell in Cloud Shell (Preview)](media/overview/overview-ps-pic.png)
3333

3434
## Features
3535
### Browser-based shell experience
@@ -38,19 +38,22 @@ Leverage Cloud Shell to work untethered from a local machine in a way only the c
3838

3939
### Choice of preferred shell experience
4040
Azure Cloud Shell gives you the flexibility of choosing the shell experience that best suits the way you work.
41-
Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.
41+
Linux users can opt for Bash in Cloud Shell, while Windows users can opt for PowerShell in Cloud Shell (Preview).
4242

43-
### Pre-configured Azure workstation
44-
Cloud Shell comes pre-installed with popular command-line tools and language support so you can work faster.
43+
### Authenticated and configured Azure workstation
44+
Cloud Shell comes managed by Microsoft so it is pre-installed with popular command-line tools and language support so you can work faster. Additionally, Cloud Shell securely authenticates automatically for instant access to your resources through the Azure CLI 2.0 or Azure PowerShell cmdlets.
4545

46-
View the full tooling list for [Bash experience](features.md#tools) and [PowerShell experience.](features-powershell.md#tools)
46+
View the full tooling list for the [Bash experience](features.md#tools) and [PowerShell (Preview) experience.](features-powershell.md#tools)
4747

48-
### Automatic authentication
49-
Cloud Shell securely authenticates automatically on each session for instant access to your resources through the Azure CLI 2.0 or Azure PowerShell cmdlets.
48+
### Multiple access points
49+
In addition to Cloud Shell being available from the Azure portal, it can also be accessed from:
50+
* [Azure CLI 2.0 "Try It" documentation](https://docs.microsoft.com/cli/azure/overview?view=azure-cli-latest)
51+
* [Azure mobile app](https://azure.microsoft.com/features/azure-portal/mobile-app/)
52+
* [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account)
5053

51-
### Connect your Azure File storage
54+
### Connect your Azure Files storage
5255
Cloud Shell machines are temporary and as a result require an Azure Files share to be mounted as `clouddrive` to persist your $Home directory.
53-
On first launch Cloud Shell prompts to create a resource group, storage account, and file share on your behalf. This is a one-time step and will be automatically attached for all sessions. A single file share can be mapped and will be used by both Bash and PowerShell in Cloud Shell.
56+
On first launch Cloud Shell prompts to create a resource group, storage account, and file share on your behalf. This is a one-time step and will be automatically attached for all sessions. A single file share can be mapped and will be used by both Bash and PowerShell in Cloud Shell (Preview).
5457

5558
#### Create new storage
5659
![](media/overview/basic-storage.png)
@@ -82,18 +85,18 @@ Dropdowns are filtered for your assigned Cloud Shell region and locally/globally
8285
* Cloud Shell is assigned one machine per user account
8386
* Permissions are set as a regular Linux user (Bash)
8487

85-
Learn more about features in [Bash in Cloud Shell](features.md) and [PowerShell in Cloud Shell](features-powershell.md).
88+
Learn more about features in [Bash in Cloud Shell](features.md) and [PowerShell in Cloud Shell (Preview)](features-powershell.md).
8689

8790
## Examples
8891
* Use scripts to automate Azure management tasks
8992
* Simultaneously manage Azure resources via Azure portal and Azure command-line tools
9093
* Test-drive Azure CLI 2.0 or Azure PowerShell cmdlets
9194

92-
Try out these examples in quickstarts for [Bash in Cloud Shell](quickstart.md) and [PowerShell in Cloud Shell](quickstart-powershell.md).
95+
Try out these examples in quickstarts for [Bash in Cloud Shell](quickstart.md) and [PowerShell in Cloud Shell (Preview)](quickstart-powershell.md).
9396

9497
## Pricing
9598
The machine hosting Cloud Shell is free, with a pre-requisite of a mounted Azure Files share. Regular storage costs apply.
9699

97-
## Supported browsers
98-
Cloud Shell is recommended for Chrome, Edge, and Safari.
99-
While Cloud Shell is supported for Chrome, Firefox, Safari, IE, and Edge, Cloud Shell is subject to specific browser settings.
100+
## Next steps
101+
[Bash in Cloud Shell quickstart](quickstart.md)
102+
[PowerShell in Cloud Shell (Preview) quickstart](quickstart-powershell.md)

articles/cloud-shell/persisting-shell-storage-powershell.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Persist files in Azure Cloud Shell (Preview) | Microsoft Docs
2+
title: Persist files in PowerShell in Azure Cloud Shell (Preview) | Microsoft Docs
33
description: Walkthrough of how Azure Cloud Shell persists files.
44
services: azure
55
documentationcenter: ''
@@ -18,8 +18,8 @@ ms.author: damaerte
1818
---
1919
[!include [features-introblock](../../includes/cloud-shell-persisting-shell-storage-introblock.md)]
2020

21-
## How Cloud Shell works
22-
Cloud Shell persists files through the following method:
21+
## How PowerShell in Azure Cloud Shell (Preview) works
22+
PowerShell in Cloud Shell (Preview) persists files through the following method:
2323
* Mounting your specified file share as `clouddrive` in your `$Home` directory for direct file-share interaction.
2424

2525
## List Cloud Drive file shares

articles/cloud-shell/persisting-shell-storage.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Persist files for Bash in Azure Cloud Shell (Preview) | Microsoft Docs
2+
title: Persist files for Bash in Azure Cloud Shell | Microsoft Docs
33
description: Walkthrough of how Bash in Azure Cloud Shell persists files.
44
services: azure
55
documentationcenter: ''
@@ -19,8 +19,8 @@ ms.author: juluk
1919

2020
[!include [features-introblock](../../includes/cloud-shell-persisting-shell-storage-introblock.md)]
2121

22-
## How Cloud Shell storage works
23-
Cloud Shell persists files through both of the following methods:
22+
## How Bash in Cloud Shell storage works
23+
Bash in Cloud Shell persists files through both of the following methods:
2424
* Creating a disk image of your `$Home` directory to persist all contents within the directory. The disk image is saved in your specified file share as `acc_<User>.img` at `fileshare.storage.windows.net/fileshare/.cloudconsole/acc_<User>.img`, and it automatically syncs changes.
2525
* Mounting your specified file share as `clouddrive` in your `$Home` directory for direct file-share interaction. `/Home/<User>/clouddrive` is mapped to `fileshare.storage.windows.net/fileshare`.
2626

@@ -88,6 +88,6 @@ justin@Azure:~$
8888
[!include [features-introblock](../../includes/cloud-shell-persisting-shell-storage-endblock.md)]
8989

9090
## Next steps
91-
[Cloud Shell Quickstart](quickstart.md) <br>
92-
[Learn about Azure File storage](https://docs.microsoft.com/azure/storage/storage-introduction#file-storage) <br>
91+
[Bash in Cloud Shell Quickstart](quickstart.md) <br>
92+
[Learn about Microsoft Azure Files storage](https://docs.microsoft.com/azure/storage/storage-introduction#file-storage) <br>
9393
[Learn about storage tags](https://docs.microsoft.com/azure/azure-resource-manager/resource-group-using-tags) <br>

0 commit comments

Comments
 (0)