diff --git a/.gitignore b/.gitignore index 5996ada..69debd9 100644 --- a/.gitignore +++ b/.gitignore @@ -421,4 +421,9 @@ local.settings.json # Java files target/ -.idea/ \ No newline at end of file +.idea/ +# Azure Developer CLI +.azure/ + +# npm artifact from language: js workaround +package-lock.json diff --git a/azure.yaml b/azure.yaml index 5386164..82227d0 100644 --- a/azure.yaml +++ b/azure.yaml @@ -3,15 +3,13 @@ name: functions-quickstart-powershell-azd metadata: template: functions-quickstart-powershell-azd@0.0.2-beta -hooks: - postprovision: - windows: - shell: pwsh - run: ./scripts/deploy.ps1 - interactive: true - continueOnError: false - posix: - shell: sh - run: ./scripts/deploy.sh - interactive: true - continueOnError: false +services: + api: + project: ./src/ + # NOTE: language is set to 'js' as a workaround -- azd has no built-in + # packager for PowerShell. The 'js' packager uses generic ZIP packaging + # which works for any runtime. The actual runtime is set via + # FUNCTIONS_WORKER_RUNTIME=powershell in Bicep. + language: js + remoteBuild: false + host: function diff --git a/scripts/deploy.ps1 b/scripts/deploy.ps1 deleted file mode 100755 index f15f41b..0000000 --- a/scripts/deploy.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -$output = azd env get-values - -foreach ($line in $output) { - if (!($line)){ - break - } - $name = $line.Split('=')[0] - $value = $line.Split('=')[1].Trim('"') - Set-Item -Path "env:\$name" -Value $value -} - -Write-Host "Environment variables set." - -$tools = @("az", "func") - -foreach ($tool in $tools) { - if (!(Get-Command $tool -ErrorAction SilentlyContinue)) { - Write-Host "Error: $tool command line tool is not available, check pre-requisites in README.md" - exit 1 - } -} - -cd ./src -func azure functionapp publish $env:AZURE_FUNCTION_NAME --powershell - -Write-Host "Deployment completed." -cd ../ \ No newline at end of file diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100755 index 54e80ab..0000000 --- a/scripts/deploy.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -output=$(azd env get-values) - -while IFS= read -r line; do - name=$(echo $line | cut -d'=' -f1) - value=$(echo $line | cut -d'=' -f2 | sed 's/^"\|"$//g') - export $name=$value - echo "$name=$value" -done <<<$output - -echo "Environment variables set." - -commands=("az" "func") - -for cmd in "${commands[@]}"; do - if ! command -v "$cmd" &>/dev/null; then - echo "Error: $cmd command is not available, check pre-requisites in README.md" - exit 1 - fi -done - -cd ./src -func azure functionapp publish $AZURE_FUNCTION_NAME --powershell - -echo "Deployed successfully." -cd ../ diff --git a/src/package.json b/src/package.json new file mode 100644 index 0000000..f253f4c --- /dev/null +++ b/src/package.json @@ -0,0 +1,5 @@ +{ + "name": "functions-quickstart-powershell-azd", + "version": "1.0.0", + "description": "PowerShell Functions quickstart - no JS dependencies needed (azd packaging stub)" +} diff --git a/src/profile.ps1 b/src/profile.ps1 index cecfdd0..c573688 100644 --- a/src/profile.ps1 +++ b/src/profile.ps1 @@ -11,10 +11,10 @@ # Authenticate with Azure PowerShell using MSI. # Remove this if you are not planning on using MSI or Azure PowerShell. -if ($env:MSI_SECRET) { - Disable-AzContextAutosave -Scope Process | Out-Null - Connect-AzAccount -Identity -} +# if ($env:MSI_SECRET) { +# Disable-AzContextAutosave -Scope Process | Out-Null +# Connect-AzAccount -Identity +# } # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell. # Enable-AzureRmAlias