Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 32 additions & 1 deletion 056-CosmicTroubleshooting/Student/Challenge-00.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,37 @@ You might not need all of them for the hack you are participating in. However, i
- [VS Code plugin for Bicep](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep)
- [Azure Storage Explorer](../../000-HowToHack/WTH-Common-Prerequisites.md#azure-storage-explorer)

If you want you can use Visual Studio Code Dev Containers or GitHub Codespaces then check out the [Dev Containers](#dev-containers) section.

### Dev Containers

#### Visual Studio Code Dev Containers

To start the environment in a local container:

- [Setup Dev Containers](https://code.visualstudio.com/docs/devcontainers/tutorial)
- You can open VS Code in the extracted `Resources.zip` and use the Use the **Dev Containers: Reopen in Container** command from the Command Palette (`F1`, `⇧⌘P`)

#### GitHub Codespaces

To start the environment in the GitHub Codespaces:

- Install [GitHub CLI](https://cli.github.com/)
- Open terminal in
Bash:
```
# Login to GitHub CLI
gh auth login
# Initialize git repo and do initial commit
git init -b main
git add . && git commit -m "initial commit"
# Create private repo in your GitHub account and push files
gh repo create WTH-CosmicTroubleshooting --source=. --private --push
```
- Go to [GitHub Codespaces](https://github.com/codespaces/new) and create new selecting your repository (your `username/WTH-CosmicTroubleshooting`)

[How to work with GitHub Codespaces](https://docs.github.com/en/codespaces/developing-in-codespaces/developing-in-a-codespace)

## Description

Now that you have the common prerequisites installed on your workstation, there are prerequisites specific to this hack.
Expand Down Expand Up @@ -63,7 +94,7 @@ Please deploy the infrastructure by running one of the following scripts in the
```
- Bash:
```
# Make sure your machine has the prerequisites
# Make sure your machine has the prerequisites (for Github Codespaces and Visual Studio Code Dev Containers use ./setup-machine-codespaces.sh)
# Also does an "az login"
./setup-machine.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
{
"name": "C# (.NET)",
"image": "mcr.microsoft.com/devcontainers/dotnet:0-6.0",
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/eitsupi/devcontainer-features/jq-likes:0": {}
},
"customizations": {
"vscode": {
"settings": {
"omnisharp.defaultLaunchSolution": "Challenge00/WTHAzureCosmosDB.sln"
},
"extensions": [
"ms-vscode.vscode-node-azure-pack",
"ms-azuretools.vscode-bicep",
"azps-tools.azps-tools",
"ms-vscode.PowerShell"
]
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// Use 'postCreateCommand' to run commands after the container is created./notifications/
// "postCreateCommand": "dotnet restore",
"postCreateCommand": "dotnet restore Challenge00/WTHAzureCosmosDB.sln && pwsh -Command Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
82 changes: 82 additions & 0 deletions 056-CosmicTroubleshooting/Student/Resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
### DotnetCore ###
# .NET Core build folders
bin/
obj/

# Common node modules locations
/node_modules
/wwwroot/node_modules

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

echoerr() { printf "\033[0;31m%s\n\033[0m" "$*" >&2; }
echosuccess() { printf "\033[0;32m%s\n\033[0m" "$*" >&2; }

# check installed tooling
echo "Testing tools:";
az version
if [ $? == 0 ]; then
echosuccess "[.] az cli tool...OK";
else
echoerr "Error with 'az cli' tool!";
exit 1;
fi


az bicep version
if [ $? == 0 ]; then
echosuccess "[.] bicep support...OK";
else
echo "Installing bicep"
az bicep install
exit 1;
fi


dotnet --version
if [ $? == 0 ]; then
echosuccess "[.] dotnet support...OK";
else
echoerr "Error with dotnet!";
exit 1;
fi

jq --version
if [ $? == 0 ]; then
echosuccess "[.] jq tool...OK";
else
echoerr "Error with 'jq' tool!";
exit 1;
fi

echo "Asking user to log in...";
# ask user for login
az login
if [ $? == 0 ]; then
echosuccess "
Your machine should be ready! Now proceed with ./deploy.sh script

";
else
echoerr "Login into Azure failed!";
exit 1;
fi
# set executable bit on ./deploy.sh
chmod +x ./deploy.sh