You can follow different path in order to publish your package into nuget.org. 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:
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.
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
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
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 Connect-AzureAD # 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 'p.panahy@company.nl'
# Show all rights I've got
Get-AzRoleAssignment-SignInName 'p.panahy@company.nl'-ExpandPrincipalGroups ` |Sort-Object-Property DisplayName ` |Select-Object ObjectType, RoleDefinitionName, DisplayName, Scope ` |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
In this page we are going to add some tasks in Azure Release pipeline to do the tests.
Prerequisites
There is already a docker image containing Zap2 files and a Python file called zap-baseline.py 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:
OWASP in Azure CLI which stes up a Container Instance that runs the tests
Transforming PowerShell Script which uses a PowerShell script to transform the result into NUnit
Publish Test Results which makes the result visible in the pipeline as Test Results
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 azurecr.io container registry and specify the Image:Tag you want to serve.
My tempate looks something inline with the following:
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: DOCKER_REGISTRY_SERVER_URL, DOCKER_REGISTRY_SERVER_USERNAME, DOCKER_REGISTRY_SERVER_PASSWORD
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:
The purpose of this page is to show the steps to create a simple webapp running as a docker container in Azure.
Create Container Registry
I am using a new Azure Container Registry in my resource group called SecuredContainerRegistry which I will refer to throughout this page. I have created this using a Basic SKU which is sufficient enough for this purpose. If you need a private endpoint you need to change he SKU to premium.
The main change after creating the Container Registry using Default options is to enable Admin user which allows us to login used by docker.
Next important change we do on this resource is to register this resource in AAD by giving it a System assigned Identity using the portal.
Add Service connection
Next you need to add a service connection in your Azure Devops project using service principal authentication that to get access to Azure Container Registry. In the popup select Azure Container registery as Registry type, then select your azure container registry and give the service connection a name.
Buid and Deploy Docker project
Create a .net core application including a Dockerfile for windows. When you choose in Visual Studio it generates a Dockerfile which is not completely working. The following example is changed version of that file which works fine:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["*.csproj", "SecuredWebApi/"]
RUN dotnet restore "SecuredWebApi/SecuredWebApi.csproj"
WORKDIR "/src/SecuredWebApi"
COPY . .
RUN dotnet build "SecuredWebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "SecuredWebApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SecuredWebApi.dll"]
Create Container Instance
Next step is to create an Azure Container instance. In my example I gave it the name container-instance. During the creation you need to connect this to a container registry. You can choose Azure Container Registry created in the first step above. Once you have a successful build you will have an image available to associate it with it. Based on my sample project I named this instance secured-container-instance and Azure portal automatically recognizes the container registery when you select the Image Source from Azure Container Registry. For this project I exposed ports 80 and port 443
By starting the instance on Container the image gets pulled and deployed in the container instance. On the Azure Portal you can look into the public ip adress and check the website is running and accessible.
A container instance can be started using docker command: docker run securedcontainerregistry.azurecr.io/securedazurelib:latest The following job tasks will start an instance in an Azure pipeline
jobs: - job: RunTest
workspace:
clean: all
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: securedcontainerregistry
- script: |
docker run securedcontainerregistry.azurecr.io/somerepo/securedazurelib:latest
Security
You can register the container instance in AAD using Manage Identity and then assign a role in KeyVault for that identity to allow access to secrets.
You may want to use a password in a template (let’s say user password of a VM or admin password of a SQL-server). Putting the password in your template, which is located in your source code repository, is not according to security guidelines.
One option to secure your strings would be to put them in KeyVault as a Secret and refer them from either paramters.json or in your main.json where it refer to a linked template.
First you need to set Azure Resource Manager for template deployment on checked within Access Policies of the keyvault where the template is refering to.
Deploying Templates
You could start a deployment right from the portal by adding a resource of type Template Deployment.
Another option would be using az CLI:
az deployment group create --resource-group newgrp1 --template-file main.json --parameters parameters.json
Or you could deploy it from your CD-pipeline locatedin Azure Devops.
Using Secured Secrets in Parameters.json
The following example refers to a secret called vmpassword within a keyvault called demovault10001 ie. located in newgrp1 resource group:
Similar to above example we can refer to a secured password by setting the keyvault id and the secret name. In the following example we use this to pass the adminPassword as a parameter to nested template.