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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __blobstorage*
__azurite*
__queuestorage*
debug.ps1
local.settings.json
21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"label": "CopyModuleFiles",
"type": "shell",
"command": "Invoke-Build -Task CopyModuleFiles -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task CopyModuleFiles -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand All @@ -17,6 +20,9 @@
"label": "Test",
"type": "shell",
"command": "Invoke-Build -Task Test -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task Test -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand All @@ -27,6 +33,9 @@
"label": "Startfunction",
"type": "shell",
"command": "Invoke-Build -Task Startfunction -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task Startfunction -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand All @@ -37,6 +46,9 @@
"label": "Clean",
"type": "shell",
"command": "Invoke-Build -Task Clean -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task Clean -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand All @@ -47,6 +59,9 @@
"label": "Testfunction",
"type": "shell",
"command": "Invoke-Build -Task TestFunction -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task TestFunction -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand All @@ -57,6 +72,9 @@
"label": ".",
"type": "shell",
"command": "Invoke-Build -Task . -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task . -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand All @@ -71,6 +89,9 @@
"label": "?",
"type": "shell",
"command": "Invoke-Build -Task ? -File './aipas.build.ps1'",
"osx": {
"command": "pwsh -c Invoke-Build -Task ? -File './aipas.build.ps1'"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
Expand Down
91 changes: 25 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,54 +143,13 @@ Azure Subscription with:

## Local development

If you want to further develop or test AIPAS you need to install the following prerequisites on your Windows development machine.

### Install local development prerequisites

- Git client
- Visual Studio Code
- Azure Function Core Tools (version 3.0.3160 or higher)
- PowerShell (Core)
- HTTP Testing and Debugging tool like [Httpmaster](https://www.httpmaster.net/) of [Insomnia](https://insomnia.rest/)

If you installed [Chocolatey](https://chocolatey.org/) (a Windows Apt-Get kinda tool) you can install above software with the following commands:

```PowerShell
# Install Git
choco install git
# Install VSCode
choco install vscode
# Install Azure Function Core Tools
choco install azure-functions-core-tools-3
# Install PowerShell Core
choco install pwsh
# Install HttpMaster
choco install httpmaster-express
```
AIPAS uses Azure Functions. You can develop, test and run Azure functions locally on your machine. Please see the [instructions](docs/prerequisites.md) for installing the prerequisites on Windows and MacOs.

### Clone AIPAS Repository

```PowerShell
git clone https://github.com/stefanstranger/AIPAS.git
```

### Install PowerShell Modules

After cloning the Git Repository you can use the bootstrap.ps1 script to install the required PowerShell modules.

![Bootstrap screenshot](pictures/bootstrap.png)

The following PowerShell Modules need to be installed:

- InvokeBuild
- Pester
- PlatyPS
- Az PowerShell modules*

\* The installation of the Az PowerShell modules are not part of the bootstrap.ps1 script. If you have not installed these PowerShell modules run Install-Module -Name Az on your development machine.



### Deploy Azure Storage Table

Within the Git Repository there are Azure Resource Manager Template files that can be used to deploy a new Resource Group with an Azure Storage Table.
Expand All @@ -202,18 +161,13 @@ Run the following PowerShell Azure commands:
Run from within your cloned repo folder
#>

$subscription = '<enter your Azure subscription Id>'

#region Login to Azure
Add-AzAccount
#endregion

#region Select Azure Subscription
$subscription =
(Get-AzSubscription |
Out-GridView `
-Title 'Select an Azure Subscription ...' `
-PassThru)

Set-AzContext -SubscriptionId $subscription.subscriptionId -TenantId $subscription.TenantID
Set-AzContext -SubscriptionId $subscription.subscriptionId
#endregion

#region Create a new Resource Group
Expand Down Expand Up @@ -257,20 +211,14 @@ $RoleDefinitionName = "Storage Account Contributor"
$ADApplicationName = "AIPAS"
$PlainPassword = "[enter password for SPN]"
$StorageAccountName = "[Configure here the name of the previously deployed Storage Account]"
$SubscriptionId = "[enter subscriptionid]"" #SubscriptionId where the Vnets will be deployed. E.g. the Landing Zone Subscription. If multiple Subscriptions are used rerun for each Subscription
$SubscriptionId = "[enter subscriptionid]" #SubscriptionId where the Vnets will be deployed. E.g. the Landing Zone Subscription. If multiple Subscriptions are used rerun for each Subscription

#region Login to Azure
Add-AzAccount
#endregion

#region Select Azure Subscription
$subscription =
(Get-AzSubscription |
Out-GridView `
-Title 'Select an Azure Subscription ...' `
-PassThru)

Set-AzContext -SubscriptionId $subscription.subscriptionId -TenantId $subscription.TenantID
Set-AzContext -SubscriptionId $SubscriptionId
#endregion

#region create SPN with Password
Expand All @@ -294,14 +242,25 @@ Get-AzADServicePrincipal -ServicePrincipalName $($app.ApplicationId.Guid) -OutVa
} | Convertto-json
#endregion

#region create local environment variables
[Environment]::SetEnvironmentVariable("AIPASClientId", "$($app.ApplicationId)", "User")
[Environment]::SetEnvironmentVariable("AIPASClientSecret", "$PlainPassword", "User")
[Environment]::SetEnvironmentVariable("AIPASSubscriptionId", "$($subscription.subscriptionId)", "User")
[Environment]::SetEnvironmentVariable("AIPAStenantId", "$($subscription.TenantID)", "User")
[Environment]::SetEnvironmentVariable("AIPASResourceGroupName", $ResourceGroupName, "User")
[Environment]::SetEnvironmentVariable("AIPASStorageAccountName", $StorageAccountName, "User")
# Restart VSCode to have access to the environment variables
#region create local settings file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rwaal

For running the Pester tests located in the IPAM PowerShell Module environment variables are used. So these still need to be created on your local development machine

$json = @"
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME_VERSION": "~7",
"FUNCTIONS_WORKER_RUNTIME": "powershell",
"AIPASStorageAccountName": "$StorageAccountName",
"AIPASTenantId": "$((Get-AzContext).Tenant.Id)",
"AIPASSubscriptionId": "$SubscriptionId",
"AIPASResourceGroupName": "$ResourceGroupName",
"AIPASClientId": "$($app.ApplicationId)",
"AIPASClientSecret": "$PlainPassword"
}
}
"@
$json | Out-File -Path .vscode\local.settings.json
# Restart VSCode to load the local settings
#endregion
```

Expand Down
60 changes: 60 additions & 0 deletions docs/prerequisites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Installing prerequisites

The following things are required on your system.

- git
- VS Code
- Azure Function Core Tools (version 3.0.3160 or higher)
- PowerShell 7
- HTTP Testing and Debugging tool like [Postman](https://www.postman.com/), [Httpmaster](https://www.httpmaster.net/) or [Insomnia](https://insomnia.rest/)


## Windows

The prerequisites on Windows can be installed using [Chocolatey](https://chocolatey.org/) (a package manager for Windows).

```
# Install Git
choco install git
# Install VSCode
choco install vscode
# Install Azure Function Core Tools
choco install azure-functions-core-tools-3
# Install PowerShell Core
choco install pwsh
# Install HttpMaster
choco install httpmaster-express
```

## MacOs
The prerequisites on MacOs can be installed using [brew](https://brew.sh/) (a package manager for Mac).

```
# Install Git
brew install git
# Install VSCode
brew install --cask visual-studio-code
# Install dotnet
brew tap caskroom/caskbrew cask install dotnet
# Install Azure Function Core Tools
brew install azure-functions-core-tools@3
# Install PowerShell 7
brew install --cask powershell
# Install Postman (alternative to httpmaster, which is only available for Windows)
brew install --cask postman
```

## Install PowerShell Modules

After cloning the Git Repository you can use the bootstrap.ps1 script to install the required PowerShell modules.

![Bootstrap screenshot](/pictures/bootstrap.png)

The following PowerShell Modules need to be installed:

- InvokeBuild
- Pester
- PlatyPS
- Az PowerShell modules*

\* The installation of the Az PowerShell modules are not part of the bootstrap.ps1 script. If you have not installed these PowerShell modules run `Install-Module -Name Az`on your development machine.