Thursday, May 27, 2021

Publish packages to

You can follow different path in order to publish your package into The prerequisites and the steps are described in Microsoft documentation page

If you get an Error 403 (The specified API Key is invalid, has expired, or does not have permission to access the specified package.) it simply indicates that the package name you chose has already been published and you are not allowed to overwrite it. Which makes sense when you upload yours and do not want other people make changes to it without you providing them an API Key.

One good practice is to create packages using a different API key than upgrading to a new version. This will make sure that your deployment pipeline will fail if the name does not exist and it would create a new package every time you deploy it.

When publishing a nuget package to Azure DevOps Artifacts you do similarly using nuget push command:

    - taskDotNetCoreCLI@2
      displayName'dotnet push'
      conditionand(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

Wednesday, May 26, 2021

Test & Feedback extension

 This extension can be installed on Chrome, Edge and FireFox in any operating systems. You simply connect the extension to your organization Azure Devops. It helps you write notes, take screenshots and add a bug when you exploring the website your team is responsible for.

See more: 

You can even work in Standalone mode which makes the report in your Download folder of the browser.

Azure Synapse Analytics Day

This page summarizes some highlights from the Azure Immersion Workshop on Analytics.

On GitHub:

What is Delta Lake: from 

Delta Lake is an open-source storage layer that brings ACID (atomicity, consistency, isolation, and durability) transactions to Apache Spark and big data workloads.

It supports many features lie ACID, Time Travel and Open format which enables Apache Parquet into baseline

Comparing Synapse Analytics versus Azure Data Factory 

Tutorial: Get Started

White Paper: POLARIS - The Distributed SQL Engine in Azure Synapse 

Unleash Your SAP Data

Experience with free account

Friday, May 21, 2021

Application Insights - Sampling


In Application Insights, using sampling is an effective way to reduce the amount of telemetry data that is sent to Application Insights. If you are worried about high storage costs if all telemetry data gets sent to Application Insights, you can make use of sampling in Application Insights.

By default Application Insights sampling is already enabled when you use the ASP.NET, ASP.NET Core software development kits.

For ASP.Net applications you can configure adaptive sampling by tuning parameters in the ApplicationInsights.config file. Some of the settings are


This will ensure to limit the number of items that are sent to Application Insights


This is the interval at which the current rate of telemetry is reevaluated


This is the amount of telemetry data that is sent when the application is started

In ASP.Net Core applications, there is no ApplicationInsights.config file, so the configuration is done via code.

Adaptive sampling is enabled by default for all ASP.NET Core applications

For more information on adaptive sampling, you can use the below link

Thursday, May 20, 2021

Azure Active Directory Commands

You may request to read registrations in AAD even if you have not enough permissions to do that from the Azure Portal. You can, for example request the name of the groups you are in, or even the members of a group or an application.

First thing you need to do in PowerShell is to make sure you have Azure AD module installed. Then you need to log into your Azure AD

## Connect to Azure AD
# In case Connect-AzureAD is not recognized as a cpommandlet, install it:
# Install-Module AzureAD -Force

Now you can query the AAD. The following are some samples:

# Get the name of applications that I have been part of?
Get-AzureADUser -SearchString "Pouya Panahy" | Get-AzureADUserAppRoleAssignment -All $true

# Get the list of groups that I am part of Get-AzureADUser -SearchString "Pouya Panahy" ` | Get-AzureADUserMembership -All $true ` | Sort-Object -Property DisplayName

# Where am I direct descendent from Get-AzRoleAssignment -SignInName ''

# Show all rights I've got Get-AzRoleAssignment -SignInName '' -ExpandPrincipalGroups `
| Sort-Object -Property DisplayName `
| Select-Object ObjectType, RoleDefinitionName, DisplayName, Scope `
| Format-Table

# Is my application registered? Get-AzureADUser -SearchString "Pouya Panahy" `
| Get-AzureADUserCreatedObject -All $true `
| Sort-Object -Property ObjectType `
| Select-Object ObjectType, AppId, DisplayName, HomePage, IdentifierUris `
| Format-Table

# Looking for an application that some one else have registered Get-AzureADServicePrincipal -All $true -Filter "startswith(DisplayName, 'AppName')"

# Who has access to my resources in a given resource group? Get-AzRoleAssignment -Scope "/subscriptions/xxxxxxxx-xxxx-xxxx-dxxx-xxxxxxxxxxxx/resourceGroups/res-grp-name" `
| Sort-Object -Property RoleDefinitionName, DisplayName `
| Select-Object ObjectType, RoleDefinitionName, DisplayName, Scope `
| Format-Table

# List the members of a group Get-AzureAdGroup -All $true -SearchString 'Group Name' | Get-AzureADGroupMember

Friday, May 14, 2021

OWASP test in Release Pipeline

 In this page we are going to add some tasks in Azure Release pipeline to do the tests.


There is already a docker image containing  Zap2 files and a Python file called to run the process. The image is called owasp/zap2docker-stable requires a shared folder to put the report in it. To mount a file share I use a storage account in azure containing the shared location called security. I generate the Key to access the shared location and start the process.

When process has been completed you need to have a file called OWASPToNUnit3.xslt to convert the report into an NUnit file that can be published as a test result.

OWASP Stage Tasks

 There are 3 tasks in this stage:

  1. OWASP in Azure CLI 
    which stes up a Container Instance that runs the tests

  2.  Transforming PowerShell Script
    which uses a PowerShell script to transform the result into NUnit

  3. Publish Test Results
    which makes the result visible in the pipeline as Test Results

Stage Tasks Yaml

steps: - task: AzureCLI@2 displayName: 'OWASP in Azure CLI ' inputs: azureSubscription: 'Owasp_grp_sp' scriptType: ps scriptLocation: inlineScript inlineScript: | $key='"the-Key-to-Storage-Account-shared-location=="' $ZAP_COMMAND="/zap/ -t """"https://the-url-to-test.something"""" -x OWASP-ZAP-Report.xml" az container create `
--resource-group owasp_grp `
--name owasp ` --image owasp/zap2docker-stable ` --ip-address public `
--ports 8080 `
--azure-file-volume-account-name owaspstore1000 `
--azure-file-volume-account-key $key `
--azure-file-volume-share-name security `
--azure-file-volume-mount-path /zap/wrk/ `
--command-line $ZAP_COMMAND az storage file download `
--account-name owaspstore1000 `
--account-key $key `
-s security `
-p OWASP-ZAP-Report.xml `
- powershell: | ## The powershell task for converting the test report $XslPath = "$($Env:SYSTEM_DEFAULTWORKINGDIRECTORY)\_Managed-Security/OWASPToNUnit3.xslt" $XmlInputPath = "$($Env:SYSTEM_DEFAULTWORKINGDIRECTORY)\OWASP-ZAP-Report.xml" $XmlOutputPath = "$($Env:SYSTEM_DEFAULTWORKINGDIRECTORY)\Converted-OWASP-ZAP-Report.xml" $XslTransform = New-Object System.Xml.Xsl.XslCompiledTransform $XslTransform.Load($XslPath) $XslTransform.Transform($XmlInputPath, $XmlOutputPath) displayName: 'Transforming PowerShell Script'

- task: PublishTestResults@2 displayName: 'Publish Test Results Converted-OWASP-ZAP-Report.xml' inputs: testResultsFormat: NUnit testResultsFiles: 'Converted-OWASP-ZAP-Report.xml'

Wednesday, May 12, 2021

Docker and Webapp

 In this page we will create a WebApp that serves a Docker image and see how to put it in CI/CD.

Create a Web App

If you are creating a web app in Azure portal, start with selecting Docker Container as Publish property in Basics tab. Choose Linux as Operating System. For this example a Standard SKU would just do fine.
Next, on the Docker-tab select your existing container registry and specify the Image:Tag you want to serve.

My tempate looks something inline with the following:

"resources": [ { "apiVersion": "2018-11-01", "name": "[parameters('name')]", "type": "Microsoft.Web/sites", "location": "[parameters('location')]", "tags": {}, "dependsOn": [ "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]" ], "properties": { "name": "[parameters('name')]", "siteConfig": { "appSettings": [ { "name": "DOCKER_REGISTRY_SERVER_URL", "value": "[parameters('dockerRegistryUrl')]" }, { "name": "DOCKER_REGISTRY_SERVER_USERNAME", "value": "[parameters('dockerRegistryUsername')]" }, { "name": "DOCKER_REGISTRY_SERVER_PASSWORD", "value": "[parameters('dockerRegistryPassword')]" }, { "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE", "value": "false" } ], "linuxFxVersion": "[parameters('linuxFxVersion')]", "appCommandLine": "", "alwaysOn": "[parameters('alwaysOn')]" }, "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]", "clientAffinityEnabled": false } }, { "apiVersion": "2018-11-01", "name": "[parameters('hostingPlanName')]", "type": "Microsoft.Web/serverfarms", "location": "West Europe", "kind": "linux", "tags": {}, "dependsOn": [], "properties": { "perSiteScaling": false, "maximumElasticWorkerCount": 1, "isSpot": false, "reserved": true, "isXenon": false, "hyperV": false, "targetWorkerCount": 0, "targetWorkerSizeId": 0 }, "sku": { "Tier": "Standard", "Name": "S1", "size": "S1", "family": "S", "capacity": 1 } }

As a security matter I have to point out the fact that the Web App is connecting to Azure Container Registry using 3 configuration items i.e. Server Url, Server Username and Server Password. These items are visible in Azure Portal Configuration:

Deploy Docker Image

In both cases where the Docker image gets pulled from Container Registry, you need to restart the instance in Container Instance and also in Web App Docker instance.

An other option would be to move the pull task into Azure Pipeline using. My example is defined as follows:

steps: - task: AzureRmWebAppDeployment@4 displayName: 'Deploy Azure App Service' inputs: azureSubscription: '$(Parameters.ConnectedServiceName)' appType: 'Web App for Containers (Linux)' WebAppName: '$(Parameters.WebAppName)' DockerNamespace: '' DockerRepository: '' DockerImageTag: 'latest' StartupCommand: ''