Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Created AI Converter + Added Static Web App Exec Doc #126

Merged
merged 27 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
74f8f93
added static web app exec doc
naman-msft Nov 1, 2023
1a7708f
add env variables, echoed website url at the end, formatted the doc
naman-msft Nov 2, 2023
28df129
removed the first duplicate staticwebapp show block
naman-msft Nov 2, 2023
c9476b7
made small formatting changes;
naman-msft Nov 2, 2023
b9fad3c
added github action for automated PR generation for AI-generated exec…
naman-msft Nov 27, 2023
ba5712a
added github action for automated PR generation for ai-generated-docs
naman-msft Nov 27, 2023
5f7871a
made some changes to the converter
naman-msft Nov 28, 2023
530193d
added test readme.md files
naman-msft Nov 28, 2023
9d03147
modified file name for pr
naman-msft Nov 28, 2023
ffbb3cb
modified file name for pr
naman-msft Nov 28, 2023
910b998
AI generated doc titled
naman-msft Nov 28, 2023
ab8b498
changed filename for pr
naman-msft Nov 28, 2023
468b528
changed filename for pr
naman-msft Nov 28, 2023
fc012cf
successfully tested ai pipeline for existing exec docs now testing fo…
naman-msft Nov 28, 2023
4aba19a
successfully tested ai pipeline for existing exec docs now testing fo…
naman-msft Nov 28, 2023
c9bf735
made changes to tool it now works
naman-msft Nov 29, 2023
9700a8c
cleaned the converter and removed a file from AIDocs
naman-msft Nov 29, 2023
8277b62
cleaned the code and added comments at necessary places
naman-msft Nov 29, 2023
c157a62
added input functionality for testing exec docs
naman-msft Dec 5, 2023
159e033
placed the ai tool called converter under the scripts subfolder/ai_ge…
naman-msft Dec 6, 2023
891c38f
configured the directory access and ie testing
naman-msft Dec 6, 2023
7d5acd9
amended some code
naman-msft Dec 7, 2023
97d6015
fixed curl issue while loading the app
naman-msft Jan 31, 2024
25be3f1
fixed static web app
naman-msft Jan 31, 2024
78575e9
fixed static web app
naman-msft Jan 31, 2024
62056bd
re-added linux vm doc
naman-msft Jan 31, 2024
0f3049b
fixed static web app
naman-msft Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 120 additions & 120 deletions scenarios/ocd/CreateLinuxVMAndSSH/README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
# Create a Linux VM and SSH On Azure

## Define Environment Variables

The First step in this tutorial is to define environment variables.

```bash
export RANDOM_ID="$(openssl rand -hex 3)"
export MY_RESOURCE_GROUP_NAME="myVMResourceGroup$RANDOM_ID"
export REGION=EastUS
export MY_VM_NAME="myVM$RANDOM_ID"
export MY_USERNAME=azureuser
export MY_VM_IMAGE="Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts-gen2:latest"
```

# Login to Azure using the CLI

In order to run commands against Azure using the CLI you need to login. This is done, very simply, though the `az login` command:

# Create a resource group

A resource group is a container for related resources. All resources must be placed in a resource group. We will create one for this tutorial. The following command creates a resource group with the previously defined $MY_RESOURCE_GROUP_NAME and $REGION parameters.

```bash
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
```

Results:

<!-- expected_similarity=0.3 -->
```json
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myVMResourceGroup",
"location": "eastus",
"managedBy": null,
"name": "myVMResourceGroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```

## Create the Virtual Machine

To create a VM in this resource group we need to run a simple command, here we have provided the `--generate-ssh-keys` flag, this will cause the CLI to look for an avialable ssh key in `~/.ssh`, if one is found it will be used, otherwise one will be generated and stored in `~/.ssh`. We also provide the `--public-ip-sku Standard` flag to ensure that the machine is accessible via a public IP. Finally, we are deploying the latest `Ubuntu 22.04` image.

All other values are configured using environment variables.

```bash
az vm create \
--resource-group $MY_RESOURCE_GROUP_NAME \
--name $MY_VM_NAME \
--image $MY_VM_IMAGE \
--admin-username $MY_USERNAME \
--assign-identity \
--generate-ssh-keys \
--public-ip-sku Standard
```

Results:

<!-- expected_similarity=0.3 -->
```json
{
"fqdns": "",
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "eastus",
"macAddress": "00-0D-3A-10-4F-70",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.147.208.85",
"resourceGroup": "myVMResourceGroup",
"zones": ""
}
```

### Enable Azure AD login for a Linux Virtual Machine in Azure

The following example has deploys a Linux VM and then installs the extension to enable Azure AD login for a Linux VM. VM extensions are small applications that provide post-deployment configuration and automation tasks on Azure virtual machines.

```bash
az vm extension set \
--publisher Microsoft.Azure.ActiveDirectory \
--name AADSSHLoginForLinux \
--resource-group $MY_RESOURCE_GROUP_NAME \
--vm-name $MY_VM_NAME
```

# Store IP Address of VM in order to SSH
run the following command to get the IP Address of the VM and store it as an environment variable

```bash
export IP_ADDRESS=$(az vm show --show-details --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query publicIps --output tsv)
```

# SSH Into VM

<!--## Export the SSH configuration for use with SSH clients that support OpenSSH & SSH into the VM.
Login to Azure Linux VMs with Azure AD supports exporting the OpenSSH certificate and configuration. That means you can use any SSH clients that support OpenSSH-based certificates to sign in through Azure AD. The following example exports the configuration for all IP addresses assigned to the VM:-->

<!--
```bash
yes | az ssh config --file ~/.ssh/config --name $MY_VM_NAME --resource-group $MY_RESOURCE_GROUP_NAME
```
-->

You can now SSH into the VM by running the output of the following command in your ssh client of choice

```bash
ssh -o StrictHostKeyChecking=no $MY_USERNAME@$IP_ADDRESS
```

# Next Steps

* [VM Documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/)
* [Use Cloud-Init to initialize a Linux VM on first boot](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-automate-vm-deployment)
* [Create custom VM images](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images)
* [Load Balance VMs](https://learn.microsoft.com/en-us/azure/load-balancer/quickstart-load-balancer-standard-public-cli)
# Create a Linux VM and SSH On Azure
## Define Environment Variables
The First step in this tutorial is to define environment variables.
```bash
export RANDOM_ID="$(openssl rand -hex 3)"
export MY_RESOURCE_GROUP_NAME="myVMResourceGroup$RANDOM_ID"
export REGION=EastUS
export MY_VM_NAME="myVM$RANDOM_ID"
export MY_USERNAME=azureuser
export MY_VM_IMAGE="Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts-gen2:latest"
```
# Login to Azure using the CLI
In order to run commands against Azure using the CLI you need to login. This is done, very simply, though the `az login` command:
# Create a resource group
A resource group is a container for related resources. All resources must be placed in a resource group. We will create one for this tutorial. The following command creates a resource group with the previously defined $MY_RESOURCE_GROUP_NAME and $REGION parameters.
```bash
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
```
Results:
<!-- expected_similarity=0.3 -->
```json
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myVMResourceGroup",
"location": "eastus",
"managedBy": null,
"name": "myVMResourceGroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```
## Create the Virtual Machine
To create a VM in this resource group we need to run a simple command, here we have provided the `--generate-ssh-keys` flag, this will cause the CLI to look for an avialable ssh key in `~/.ssh`, if one is found it will be used, otherwise one will be generated and stored in `~/.ssh`. We also provide the `--public-ip-sku Standard` flag to ensure that the machine is accessible via a public IP. Finally, we are deploying the latest `Ubuntu 22.04` image.
All other values are configured using environment variables.
```bash
az vm create \
--resource-group $MY_RESOURCE_GROUP_NAME \
--name $MY_VM_NAME \
--image $MY_VM_IMAGE \
--admin-username $MY_USERNAME \
--assign-identity \
--generate-ssh-keys \
--public-ip-sku Standard
```
Results:
<!-- expected_similarity=0.3 -->
```json
{
"fqdns": "",
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "eastus",
"macAddress": "00-0D-3A-10-4F-70",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.147.208.85",
"resourceGroup": "myVMResourceGroup",
"zones": ""
}
```
### Enable Azure AD login for a Linux Virtual Machine in Azure
The following example has deploys a Linux VM and then installs the extension to enable Azure AD login for a Linux VM. VM extensions are small applications that provide post-deployment configuration and automation tasks on Azure virtual machines.
```bash
az vm extension set \
--publisher Microsoft.Azure.ActiveDirectory \
--name AADSSHLoginForLinux \
--resource-group $MY_RESOURCE_GROUP_NAME \
--vm-name $MY_VM_NAME
```
# Store IP Address of VM in order to SSH
run the following command to get the IP Address of the VM and store it as an environment variable
```bash
export IP_ADDRESS=$(az vm show --show-details --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query publicIps --output tsv)
```
# SSH Into VM
<!--## Export the SSH configuration for use with SSH clients that support OpenSSH & SSH into the VM.
Login to Azure Linux VMs with Azure AD supports exporting the OpenSSH certificate and configuration. That means you can use any SSH clients that support OpenSSH-based certificates to sign in through Azure AD. The following example exports the configuration for all IP addresses assigned to the VM:-->
<!--
```bash
yes | az ssh config --file ~/.ssh/config --name $MY_VM_NAME --resource-group $MY_RESOURCE_GROUP_NAME
```
-->
You can now SSH into the VM by running the output of the following command in your ssh client of choice
```bash
ssh -o StrictHostKeyChecking=no $MY_USERNAME@$IP_ADDRESS
```
# Next Steps
* [VM Documentation](https://learn.microsoft.com/en-us/azure/virtual-machines/)
* [Use Cloud-Init to initialize a Linux VM on first boot](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-automate-vm-deployment)
* [Create custom VM images](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images)
* [Load Balance VMs](https://learn.microsoft.com/en-us/azure/load-balancer/quickstart-load-balancer-standard-public-cli)
134 changes: 134 additions & 0 deletions scenarios/ocd/CreateStaticWebApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Azure Static Web Apps Quickstart: Building Your First Static Site Using the Azure CLI

Azure Static Web Apps publishes websites to production by building apps from a code repository. In this quickstart, you deploy a web application to Azure Static Web Apps using the Azure CLI.

## Define Environment Variables

The First step in this tutorial is to define environment variables.

```bash
export RANDOM_ID="$(openssl rand -hex 3)"
export MY_RESOURCE_GROUP_NAME="myStaticWebAppResourceGroup$RANDOM_ID"
export REGION=EastUS2
export MY_STATIC_WEB_APP_NAME="myStaticWebApp$RANDOM_ID"
```

## Create a Repository (optional)

(Optional) This article uses a GitHub template repository as another way to make it easy for you to get started. The template features a starter app to deploy to Azure Static Web Apps.

- Navigate to the following location to create a new repository: https://github.com/staticwebdev/vanilla-basic/generate
- Name your repository `my-first-static-web-app`

> **Note:** Azure Static Web Apps requires at least one HTML file to create a web app. The repository you create in this step includes a single `index.html` file.

Select `Create repository`.

## Deploy a Static Web App

You can deploy the app as a static web app from the Azure CLI.

1. Create a resource group.

```bash
az group create \
--name $MY_RESOURCE_GROUP_NAME \
--location $REGION
```

Results:

<!-- expected_similarity=0.3 -->
```json
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/my-swa-group",
"location": "eastus2",
"managedBy": null,
"name": "my-swa-group",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```

2. Deploy a new static web app from your repository.

```bash
az staticwebapp create \
--name $MY_STATIC_WEB_APP_NAME \
--resource-group $MY_RESOURCE_GROUP_NAME \
--location $REGION
```

There are two aspects to deploying a static app. The first operation creates the underlying Azure resources that make up your app. The second is a workflow that builds and publishes your application.

Before you can go to your new static site, the deployment build must first finish running.

3. Return to your console window and run the following command to list the website's URL.

```bash
export MY_STATIC_WEB_APP_URL=$(az staticwebapp show --name $MY_STATIC_WEB_APP_NAME --resource-group $MY_RESOURCE_GROUP_NAME --query "defaultHostname" -o tsv)
```

```bash
runtime="1 minute";
endtime=$(date -ud "$runtime" +%s);
while [[ $(date -u +%s) -le $endtime ]]; do
if curl -I -s $MY_STATIC_WEB_APP_URL > /dev/null ; then
curl -L -s $MY_STATIC_WEB_APP_URL 2> /dev/null | head -n 9
break
else
sleep 10
fi;
done
```

Results:

<!-- expected_similarity=0.3 -->
```HTML
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8 />
<meta name=viewport content="width=device-width, initial-scale=1.0" />
<meta http-equiv=X-UA-Compatible content="IE=edge" />
<title>Azure Static Web Apps - Welcome</title>
<link rel="shortcut icon" href=https://appservice.azureedge.net/images/static-apps/v3/favicon.svg type=image/x-icon />
<link rel=stylesheet href=https://ajax.aspnetcdn.com/ajax/bootstrap/4.1.1/css/bootstrap.min.css crossorigin=anonymous />
```

```bash
echo "You can now visit your web server at https://$MY_STATIC_WEB_APP_URL"
```

## Next Steps

Congratulations! You have successfully deployed a static web app to Azure Static Web Apps using the Azure CLI. Now that you have a basic understanding of how to deploy a static web app, you can explore more advanced features and functionality of Azure Static Web Apps.

In case you want to use the GitHub template repository, follow the additional steps below.

Go to https://github.com/login/device and enter the user code 329B-3945 to activate and retrieve your GitHub personal access token.

1. Go to https://github.com/login/device.
2. Enter the user code as displayed your console's message.
3. Select `Continue`.
4. Select `Authorize AzureAppServiceCLI`.

### View the Website via Git

1. As you get the repository URL while running the script, copy the repository URL and paste it into your browser.
2. Select the `Actions` tab.

At this point, Azure is creating the resources to support your static web app. Wait until the icon next to the running workflow turns into a check mark with green background ( ). This operation may take a few minutes to complete.

3. Once the success icon appears, the workflow is complete and you can return back to your console window.
4. Run the following command to query for your website's URL.

az staticwebapp show \
--name $MY_STATIC_WEB_APP_NAME \
--query "defaultHostname"

5. Copy the URL into your browser to go to your website.