cmdlet New-AzVM at command pipeline position 1 Supply values for the following parameters: Credential User: testuser Password for user testuser: **********
No Size value has been provided. The VM will be created with the default size Standard_D2s_v3. Creating Azure resources [2% / PS /home/ramiro> Remove-AzResourceGroup -Namecli-uk-rg
PS /home/ramiro> az group create --name cli-uk-rg --location ukwest { "id": "/subscriptions/354d5e5b-ad8d-4e29-a2b4-e8e7038d7207/resourceGroups/cli-uk-rg", "location": "ukwest", "name": "cli-uk-rg", "properties": { "provisioningState": "Succeeded" }, "type": "Microsoft.Resources/resourceGroups" } PS /home/ramiro> az vm create --resource cli-uk-rg --name aznewvm2 --image win2016datacenter --size Standard_B2s --public-ip-sku Standard --admin-user testuser Admin Password: Confirm Admin Password: It is recommended to use parameter "--public-ip-sku Standard" to create new VM with Standard public IP. Please note that the default public IP used for VM creation will be changed from Basic to Standard in the future. { "fqdns": "", "id": "/subscriptions/354d5e5b-ad8d-4e29-a2b4-e8e7038d7207/resourceGroups/cli-uk-rg/providers/Microsoft.Compute/virtualMachines/aznewvm2", "location": "ukwest", "macAddress": "00-22-48-C5-C1-6F", "powerState": "VM running", "privateIpAddress": "10.0.0.4", "publicIpAddress": "51.142.142.46", "resourceGroup": "cli-uk-rg", "zones": "" }
PS /home/ramiro/html-docs-hello-world> az webapp up --location eastus --name simple-ramirobedoya-me2 -g cli-webapp-rg -p aznewasp4566 --html The webapp 'simple-ramirobedoya-me' doesn't exist Creating Resource group 'whistler092_rg_6728' ... Resource group creation complete Creating AppServicePlan 'whistler092_asp_8600' ... Creating webapp 'simple-ramirobedoya-me' ... Configuring default logging for the app, if not already enabled Creating zip with contents of dir /home/ramiro/html-docs-hello-world ... Getting scm site credentials for zip deployment Starting zip deployment. This operation can take a while to complete ... Deployment endpoint responded with status code 202 You can launch the app at http://simple-ramirobedoya-me.azurewebsites.net Setting 'az webapp up' default arguments for current directory. Manage defaults with 'az configure --scope local' --resource-group/-g default: whistler092_rg_6728 --sku default: F1 --plan/-p default: whistler092_asp_8600 --location/-l default: eastus --name/-n default: simple-ramirobedoya-me { "URL": "http://simple-ramirobedoya-me.azurewebsites.net", "appserviceplan": "whistler092_asp_8600", "location": "eastus", "name": "simple-ramirobedoya-me", "os": "Windows", "resourcegroup": "whistler092_rg_6728", "runtime_version": "-", "runtime_version_detected": "-", "sku": "FREE", "src_path": "//home//ramiro//html-docs-hello-world" }
> func init --worker-runtime dotnet --force > dotnet build Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore... All projects are up-to-date for restore. func -> ~/AZ-204-DevelopingSolutionsforMicrosoftAzure/Allfiles/Labs/02/Starter/func/bin/Debug/net6.0/func.dll
Build succeeded. 0 Warning(s) 0 Error(s)
Time Elapsed 00:00:23.16 > func new --template "HTTP trigger" --name "Echo" Select a number for template:Function name: Echo
The function"Echo" was created successfully from the "HTTP trigger" template.
> func start --build Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore... All projects are up-to-date for restore. func -> ~/AZ-204-DevelopingSolutionsforMicrosoftAzure/Allfiles/Labs/02/Starter/func/bin/output/func.dll
[2022-07-12T20:55:13.120Z] Found ~/AZ-204-DevelopingSolutionsforMicrosoftAzure/Allfiles/Labs/02/Starter/func/func.csproj. Using for user secrets file configuration.
Functions:
Echo: [POST] http://localhost:7071/api/Echo
For detailed output, run func with --verbose flag. [2022-07-12T20:55:32.745Z] Host lock lease acquired by instance ID '000000000000000000000000A4DAC17F'. [2022-07-12T20:55:38.056Z] Executing 'Echo' (Reason='This function was programmatically called via the host APIs.', Id=05254f34-ab24-4646-a5ee-ad69630ea3a2) [2022-07-12T20:55:38.068Z] C# HTTP trigger function processed a request. [2022-07-12T20:55:38.097Z] Executed 'Echo' (Succeeded, Id=05254f34-ab24-4646-a5ee-ad69630ea3a2, Duration=63ms) [2022-07-12T20:55:51.010Z] Executing 'Echo' (Reason='This function was programmatically called via the host APIs.', Id=46553eb7-3d9d-4924-81b9-8668c5b94b16) [2022-07-12T20:55:51.010Z] C# HTTP trigger function processed a request. [2022-07-12T20:55:51.010Z] Executed 'Echo' (Succeeded, Id=46553eb7-3d9d-4924-81b9-8668c5b94b16, Duration=6ms)
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore... All projects are up-to-date for restore. func -> /Users/ramiroandres/workspace/AZ-204-DevelopingSolutionsforMicrosoftAzure/Allfiles/Labs/02/Starter/func/bin/output/func.dll
[2022-07-12T20:59:30.460Z] Found /Users/ramiroandres/workspace/AZ-204-DevelopingSolutionsforMicrosoftAzure/Allfiles/Labs/02/Starter/func/func.csproj. Using for user secrets file configuration.
Functions:
Echo: [POST] http://localhost:7071/api/Echo
Recurring: timerTrigger
For detailed output, run func with --verbose flag. [2022-07-12T20:59:37.642Z] Host lock lease acquired by instance ID '000000000000000000000000A4DAC17F'. [2022-07-12T21:00:30.063Z] Executing 'Recurring' (Reason='Timer fired at 2022-07-12T16:00:30.0205030-05:00', Id=5efaae60-4145-425e-8b7a-efa03ced230c) [2022-07-12T21:00:30.122Z] C# Timer trigger function executed at: 7/12/2022 4:00:30 PM [2022-07-12T21:00:30.146Z] Executed 'Recurring' (Succeeded, Id=5efaae60-4145-425e-8b7a-efa03ced230c, Duration=107ms)
Create a function that integrates with other services
Note: off means Private (no anonymous access).
1 2 3 4 5 6 7 8
> az storage container create > az storage container create --name content --public-access off --account-name imgstorramirobedoya > func new --template "HTTP trigger" --name "GetSettingInfo" Select a number for template:Function name: GetSettingInfo
The function"GetSettingInfo" was created successfully from the "HTTP trigger" template. > > func extensions install --package Microsoft.Azure.WebJobs.Extensions.Storage --version 4.0.4
Update file with the following code
1 2 3 4 5 6 7 8 9 10 11 12 13
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs;
> az group create --name lab3-rg --location eastus > az storage account create --name mediastorramirobedoya --location eastus --resource-group lab3-rg --sku Standard_LRS
Get Endpoints > az storage account list --resource-group lab3-rg --query "[?starts_with(name, 'mediastor')].{primaryEndpoints:primaryEndpoints.blob}" -o tsv
publicstaticasync Task Main(string[] args) { var accountCredentials = new StorageSharedKeyCredential(storageAccountName, storageAccountKey); var blobServiceClient = new BlobServiceClient(new Uri(blobServiceEndpoint), accountCredentials);
AccountInfo info = await blobServiceClient.GetAccountInfoAsync();
> az acr list --query "max_by([], &creationDate).name" --output tsv conregistryramirobedoya
> acrName=$(az acr list --query "max_by([], &creationDate).name" --output tsv) echo$acrName
> cd ~/clouddrive/ipcheck > az acr build --registry $acrName --image ipcheck:latest .
> az acr repository list --name $acrName
In this exercise, you created a .NET console application to display a machine’s current IP address. You then added the Dockerfile file to the application so that it could be converted into a Docker container image. Finally, you deployed the container image to Container Registry.
Exercise 3: Deploy an Azure container instance
Open the Container registry/Overview/Update/ turn on Admin user.
1 2 3 4 5 6 7 8 9
> az container create --resource-group lab5-rg --name managedcompute1 --image conregistryramirobedoya.azurecr.io/ipcheck:latest
> az container logs --resource-group lab5-rg --name managedcompute CorCurrent IP Address: 127.0.0.1 192.168.0.120 fe80::215:5dff:fe0c:6833%2 2022-07-14T17:32:59.9145453Z stderr F
Note: After the application finishes running, the container terminates because it has completed its work. For the manually created container instance, you indicated that a successful exit was acceptable, so the container ran once. The automatically created instance didn’t offer this option, and it assumes the container should always be running, so you’ll notice repeated restarts of the container.
Lab6 - Authenticate by using OpenID Connect, MSAL, and .NET SDKs
In Function App / Settings / Identity / System Assigned / Turn Status On
For the A system assigned managed identity is restricted to one per resource and is tied to the lifecycle of this resource. You can grant permissions to the managed identity by using Azure role-based access control (Azure RBAC). The managed identity is authenticated with Azure AD, so you don’t have to store any credentials in code. Learn more about Managed identities.
In Key vault / Settings / Secrets / + Generate/Import
Create the secret
For CLI
1 2 3
> az keyvault secret set --name securevaultramirobedoya --vault-name storagecredentials1 --value "DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net;AccountName=securestorramirobedoya;AccountKey=CF/jL5NUTilxe/vpD8PuWPx0pGyB01q41/JW8qFBHRX3E40SIgZL1TuPoEYG2mhYQTtAGKxMDv2w+AStdq6CXw==;BlobEndpoint=https://securestorramirobedoya.blob.core.windows.net/;FileEndpoint=https://securestorramirobedoya.file.core.windows.net/;QueueEndpoint=https://securestorramirobedoya.queue.core.windows.net/;TableEndpoint=https://securestorramirobedoya.table.core.windows.net/"
Inside the Key Valut, Go to Settings / Access Policies / Add Access Policy / Add access Policy
Select permission to get and set the principal app for securefuncramirobedoya
Save
Task 4: Create a Key Vault-derived application setting
In the Function App, go to Settings / Configuration / Application Settings and Add a new one,
your value would be @Microsoft.KeyVault(SecretUri=https://securevaultstudent.vault.azure.net/secrets/storagecredentials/17b41386df3e4191b92f089f5efb4cbf)
using ServiceBusMessageBatch messageBatch = await sender.CreateMessageBatchAsync();
for (int i = 0; i < numOfMessages; i++) { if (!messageBatch.TryAddMessage(new ServiceBusMessage($"Message {i}"))) { thrownew Exception($"The message {i} is too large to fit in the batch."); } }
try { await sender.SendMessagesAsync(messageBatch); Console.WriteLine($"A batch of {numOfMessages} messages has been published to the queue.");
> az group create --name lab11-rg --location eastus > az monitor app-insights component create --app instrmramirobedoya --location eastus --kind web --resource-group lab11-rg --application-type web
> az appservice plan create -g lab11-rg -n appservicemonitorramirobedoya --sku S1 --location eastus --is-linux > az functionapp list-runtimes > az webapp create --name smpapiramirobedoya --resource-group lab11-rg --plan appservicemonitorramirobedoya --runtime "DOTNETCORE:6.0"
> az monitor app-insights component connect-webapp -g lab11-rg -a instrmramirobedoya --web-app smpapiramirobedoya --enable-profiler --enable-snapshot-debugger