Learn Portal link is: Microsoft Learn Portal
Table of Content:
- Azure Container App. useful exercise on Microsoft Learn
- Udemy Learn and Official Questions Pack
- Thomasmaurer blog, Azure Developer
This repo consists of materials gathering from different sources which help you to successfully pass official Microsoft Azure Developer exam.
My function v3 (most modern) example: Example in C#
My example: Prepared example in c#
My example: Prepared example in c#
- Build Azure Function with Docker:
docker build --tag alekseikolesnikov/azurefunctionsimage:v.1.0.0 .
- Run Azure Function Docker:
docker run -p 8080:80 -it alekseikolesnikov/azurefunctionsimage:v.1.0.0
- To Publish Azure Function into Container Registry you must add Docker Support to your project (you cant do that initially)
link: Durable functions example
- Useful in situations when you need to organize your work with several Functions and with People (not high-available elements)
- Useful for chain of responsibility pattern Consisft of Several Parts:
- Durable HTTP Start. Runs your queue. Runs your Durable Orchestrator (place it in "in" connection). It's your entry point and this fucntion can be used via browser.
- Durable Orchestrator Function. Runs your little Activity Functions (which can make some work).
- Durable Activity Function. Does the job.
Example workflow:
- A project design is submitted.
- An approval task is allocated to a manager, so they can review the project design proposal.
- The project design proposal is rejected or approved.
- An escalation task is allocated if the approval task isn't completed within a pre-defined time limit.
link: Orchestrator Function with Timer
- You should use durable timers in orchestrator functions instead of the setTimeout() and setInterval() functions.
Example: Watch Function Example Using Visual Studio 2019
- First you need to create Namespace:
a. Select and push to bash your selected name:NS_NAME=event-hub-namespace
b. Create Event Hub Namespace:az eventhubs namespace create --name event-hub-namespace
c. Get JSON Configuration (with connections) to your created namespace:az eventhubs namespace authorization-rule keys list --name RootManageSharedAccessKey --namespace-name $NS_NAME
- Create Event Hub:
a. New Hub Name:HUB_NAME=hubname-$RANDOM
b. Create Event Hub:az eventhubs eventhub create --name $HUB_NAME --namespace-name $NS_NAME
c. Check that Event Hub created properly:az eventhubs eventhub show --namespace-name $NS_NAME --name $HUB_NAME
The noticeable difference between them is that Event Hubs are accepting only endpoints for the ingestion of data and they don't provide a mechanism for sending data back to publishers. On the other hand, Event Grid sends HTTP requests to notify events that happen in publishers.
Good Article about the difference
Azure Event Hubs keeps received messages from your sender application, even when the hub is unavailable. Messages received after the hub becomes unavailable are successfully transmitted to our application as soon as the hub becomes available.
Event Hub, not Event Hub Namespace. You can Disable(turn off) the Event Hub to test that. All messages will appear when you turn on you Event Hub again.
Blob Storage and live example how to work with it (but library is deprecated, not a big deal anyway)
- Application works in Azure Environment. Otherwise, you have to create and define this configuration file on your own (
services.Configure<AzureStorageConfig>(Configuration.GetSection("AzureStorageConfig"));
) - Better to store this code in AppService.
-
Create a plan
az appservice plan create \ --name blob-exercise-plan \ --resource-group learn-21e4e8a8-bc24-473a-ab32-9db698dcb993 \ --sku FREE --location centralus
-
Create WebApp
az webapp create \ --name <your-unique-app-name> \ --plan blob-exercise-plan \ --resource-group learn-21e4e8a8-bc24-473a-ab32-9db698dcb993
-
get Connection string
CONNECTIONSTRING=$(az storage account show-connection-string \ --name <your-unique-storage-account-name> \ --output tsv)
-
Create AppSettings config webapp
CONNECTIONSTRING=$(az storage account show-connection-string \ --name <your-unique-storage-account-name> \ --output tsv)
Link to the BlobStorage + .Net MVC Project example: Blob Storage + MVC
-
To use az module you have to install it first! It has all commands which Azure PowerShell provides
- Azure bot can help you to find information about anything from Azure World:
azure find KEY_WORD
- to find anything tied with your keyword, i.e.azure find "blob storage create"
orazure find blob-storage-create
(first example with quotes usually works better) - To find information about proper command (like to get the list of all parameters):
az YOUR_COMMAND --help
- To find information in bash you may also use
az find "YOUR_QUESTION"
On-premise gateway & Isolated Service Environment & Direct Link | Peer-2-Site Site-2-Site. Logic App, Power BI, Power Apps connection to on-premise data and network.
Logic App Gateway Install overview
logic-apps-gateway
P2P & S2S & Express Route
Tips
Point-to-site - Established between a virtual network and a single computer in your network. Each computer that wants to establish connectivity with a virtual network must configure its connection. This connection type is great if you're just getting started with Azure, or for developers, because it requires little or no changes to your existing network.
Site-to-site VPN: Established between your on-premises VPN device and an Azure VPN Gateway that is deployed in a virtual network. This connection type enables any on-premises resource that you authorize to access a virtual network.
All cmd-lets support interactiveness.
- get all resources by Resource Group Name:
Get-AzResource -ResourceGroupName $vm.ResourceGroupName | ft
- Set Complex Variale:
$vm = (Get-AzVM -Name "testvm-eus-01" -ResourceGroupName learn-34fad52d-63cc-4ea1-a121-107041f719b7)
- Create VM:
New-AzVm -ResourceGroupName learn-34fad52d-63cc-4ea1-a121-107041f719b7 -Name "testvm-eus-01" -Credential (Get-Credential) -Location "East US" -Image UbuntuLTS -OpenPorts 22
- Get Resources by type:
Get-AzResource -ResourceType Microsoft.Compute/virtualMachines
PowerShell script example: Link
- Create WebApp (App Service):
-
- Create new Resource, WebApp in Search, Select name "web-app-learn1", Select .net stack, Review and Create
-
- Create .net project and publish it locally:
- Create .net project
- Publish .net project into folder "pub" and name it "site.zip" (
dotnet build
+cd yourProjectToPublish
+dotnet publish -o pub
) - zip all files from publishing folder with 7zip
- Publish into Azure:
- open Visual Studio Terminal
- cd pub
- az login (potentially with --tenant "yourLearnDirectory.docs.microsoft.com")
- az webapp deployment source config-zip --src site.zip --resource-group learn-cef0f929-db52-4acc-acc1-981a6ceb1852 --name web-app-learn1
- check your application
- First option is to use Local Git.
- Create local Git under App Service > Deployment Center
- Create Local Git
- Copy Local Git URL and use it to create the repo locally on PC \ in Azure
- git init, git push...
- Create production branch. Push all changes to production branch to see these changes in App Serivce.
Working with Slots (Production, Test slots within one App Service Plan (Standard, Premium and Isolated only, Free and Basic aren't supported))
Link: MS-Learn Link
Different connection links (and other dedicated configurations) for slots: link
Application Service Environment
- Create Registry
- in your project
az acr build --registry <container_registry_name> --image <selected_image_name> .
- Create azure container registry
- Build your images locally using
docker build
- add tag to your image
>docker tag <originalImageTag> <containerregistry.azurecr.io/newimagename>
- login to azure container registry:
az login
andaz acr login --name myregistry
- push your image
docker push <containerregistry.azurecr.io/newimagename>
- Create azure container registry
- Build your images locally using
docker-compose build
- add tag to your image
>docker tag <originalImageTag> <containerregistry.azurecr.io/newimagename>
- login to azure container registry:
az login
andaz acr login --name myregistry
- update your docker-compose file with new image names
image: <containerregistry.azurecr.io/newimagename>
- use
docker-compose push
PS Additional information is under quick start tab in Azure Container Registry
My example: Prepared example in c#
- Build Azure Function with Docker:
docker build --tag alekseikolesnikov/azurefunctionsimage:v.1.0.0 .
- Run Azure Function Docker:
docker run -p 8080:80 -it alekseikolesnikov/azurefunctionsimage:v.1.0.0
- To Publish Azure Function into Container Registry you must add Docker Support to your project (you cant do that initially)
Active Directory Authentication Example
Mapage Passwords in Key Vault Example Key Vault Management and Configuration Certificates KeyVault + WebApp
Tips
-
For example, if you want to grant an application the rights to use keys in a key vault, you only need to grant data plane access permissions using key vault access policies. No management plane access is needed for this application. Conversely, if you want a user to be able to read vault properties and tags but not have any access to keys, secrets, or certificates, by using RBAC, you can grant read access to the management plane. No access to the data plane is required.
-
Get secret from Key vault using Azure CLI `az keyvault secret show --vault-name --name
Cross_Site_Scripting_Prevention
tools to verify if our dependencies are vulnerable
- Data discovery and classification (currently in preview) provides advanced capabilities built into Azure SQL Database for discovering, classifying, labeling and protecting sensitive data (such as business, personal data (PII), and financial information) in your databases. Link with information
- Azure RBAC has something called
NotActions
permissions. Use NotActions to create a set of not allowed permissions. The access granted by a role, the effective permissions, is computed by subtracting the NotActions operations from the Actions operations. For example, the Contributor role has both Actions and NotActions. The wildcard (*) in Actions indicates that it can perform all operations on the control plane. Then you subtract the following operations in NotActions to compute the effective permissions
You can allow your VM to access to resource group using this identity
Two types: System-Assigned and User-Assigned. System-assigned will be deleted automatically from Azure AD is resource is deleted(VM in my example). User-Assigned will not (but may be granted to several resources)
- Good example of how to apply user-defined Managed Identity to Azure Function and Azure Storage Account: good explanation and example
- Managed Identities - overview
- Access from VM to selected resource group - also IAM example is here
- Invoke-Restmethod: let you delegate such permissions
- Invoke-WebRequest vs Invoke-Restmethod (both of them will allow you to delegate permissions to VM)