Showing posts with label Azure. Show all posts
Showing posts with label Azure. Show all posts

Sunday, April 11, 2021

how to access Azure Active Directory from other portals?

 we should all know that we can use Azure portal to access the Azure Active directory. after you log into the portal we can click on the Azure Active Directory from the left blade, or type " Azure Active Directory " in the search box to access Azure Active Directory features

However Microsoft also provide tow alternative ways to access the Azure Active Directory with same login credential as we use for azure portal.

here are the two web portals we can use to access Azure Directory.

https://admin.microsoft.com

https://myapps.microsoft.com 

Sunday, March 14, 2021

how to fix "The files of the specified task cannot be accessed as the task state is still active" in az batch task file command execution?

when we run the az batch task file list to show all the task file in batch execution. we encounter the following error immediately.

 " The specified operation is not valid for the current state of the resource.
RequestId:bfad4b09-53a4-4a7f-b9a5-d54a630699d7
Time:2021-03-14T17:17:42.8558070Z
Reason: The files of the specified task cannot be accessed as the task state is still active"

afterwe try to az batch task file download, we got the same error.

actually we can solve this issue by requesting dedicated nodes manually on the portal for that specific batch account.

 here are the steps to reach our goal.

 1. go the batch account

 


 

 

 

  

2. click on the pools item on the blade to show the pools under this batch account


 

 

 

 

 3. click on the pool name that we created for batch action.


 

 

 

 

4.click on the nodes item on the blade.

 

 






5.click on the any node under the name column to view the contents in the node





6.click on the workitems folder to view the batch  job which is myjob that we created previously


7.click on myjob folder, then click on myjob1, and click on the task1 to show the content of task1.







8. click on the stardout.txt to show the task execution result.





now we can verify our batch process manually in the azure portal.






Monday, July 13, 2020

how to setup Azure Kubernetes Service cluster and configure Kubernetes dashboard with AZ CLI?

it is very easy to create and run a  AKS cluster with few AZ CLI commands.

1. create a resource group for AKS

az group create --name dan-aks-rg --location eastus

2. create an AKS cluster

az aks create --resource-group dan-aks-rg --name dan-cluster

3.get the credentials for the cluster, this will download the credetenials and store in the config file
under this path C:\Users\admin\.kube

az aks get-credentials --resource-group dan-aks-rg --name dan-cluster

4. install the Kubernetes cli utility

az ask install-cli

5. install Kubernetes dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml

6. Access the dashboard. there are two way to access the Kubernetes dashboard.
 from AZ CLI

az aks browse --resource-group dan-aks-rg --name dan-cluster

it will automatically lauch in the web browser

http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/


or we can use kubectl proxy to access the Kubernetes Dashboard UI. Type Kubectl proxy in the CMD windows, then hit enter and launch the web chrome and paste the following url in the url windows to launch the kubernetes dashboard.

kubectl proxy 

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/overview?namespace=default

7. Trouble shot tips

if you see an empty kubernetes dashboard with warming message
"secrets is forbidden: User "clusterUser" cannot list resource "secrets" in API group "" in the namespace "default"

it is permission issue. you can resolve this following steps, you need to replace the clusterUser with specific name that was shown in your error message.

  • kubectl delete clusterrolebinding kubernetes-dashboard

    kubectl delete clusterrolebinding kubernetes-dashboard -n kube-system

    kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard --user=clusterUser

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-clusterrolebinding-em-

Sunday, March 29, 2020

how to fix "Access to XMLHttpRequest at 'http://localhost:7071/api/' from origin 'http://localhost:3000' has been blocked by CORS policy" in Azure Serverless implementation?

when i implemented the Web API using Azure functions in Azure Serverless development. i try to run the Azure fucntion in the localhost from visual studio code. the error came up immdiately after i test the create function.

"Access to XMLHttpRequest at 'http://localhost:7071/api/createSpeaker/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."

the error message clearly indicated that it was a CORS issue. which is the web app hosts on port 3000 and tries to access the web API hosts on port 7071.

according to the microsoft document. it suggested that we should add the following configuration to the local.settings.json file which is the configure file for azure functions running in local mode.

https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash

"Host": {
    "LocalHttpPort": 7071,
    "CORS": "*",
    "CORSCredentials": false
  },

however the above never works for me. acutally the following command line did fix the issue

func host start --cors *

Happy programming and enjoy the fun




Friday, March 27, 2020

How to comment out multi-line in Windows Powershell?

if we want to comment out multiple line in the Powershell ISE. there is a shotcut to do so.

comment out multi-line:

use "ALT + SHIFT" to move down to the end of the last line that you want to comment out,

then use "SHIFT + #" to add # to all lines being selected.

 uncomment multi-line:

use "ALT + SHIFT" to move down to the end of the last line that you want to uncomment,

then press Delete button to undo all the comment out code.

having more fun with PowerShell !


Sunday, March 8, 2020

Azure New Feature Azure AD Authentication Method in Preview

I just spot a new feature in the azure portal today, after i logged into portal,  i saw a new icon (
Authentication methods - Authentication method policy (Preview)
) on the home page







after i click on the icon. it will show there are two authentication method policies available





you can click on the authentication method policy to configure the settings for each method.









Thursday, February 27, 2020

How to update User Multi-Factor Authentication in Azure Active Directory?

first step you log into the azure portal


second click on the Azure Acitve Directory to launch AAD blade, then click on the Users on the blade.








third click on the Multi-Factor Authentication icon on the menu bar to launch Multi-Factor Authentication Services page











fourth click on the service setting tab to access the notification setting





 

Sunday, February 23, 2020

How to fix COPY failed COPY failed: stat /var/lib/docker/tmp/docker-builder/appFolder/App.csproj: no such file or directory issue in Docker Build command to create a docker image in Microservice project?

I am playing with the Microservices application with docker enable in my local development.

after i completely setup my project. i try to manipulate the project with docker building command.

since the dockerfile had been automatically generated by visual studio, when i create a dotnet core web api project with docker support.







how ever when i run this command to create a docker image

docker build . -t myimage -f dockerfile

it encountered an error on the copy step. i put the step with error in bold.

FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
RUN dotnet restore "simplemicroservicesApp/simplemicroservicesApp.csproj"
COPY . .
WORKDIR "/src/simplemicroservicesApp"
RUN dotnet build "simplemicroservicesApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "simplemicroservicesApp.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "simplemicroservicesApp.dll"]

here is the error message

Step 7/17 : COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder663072116/simplemicroservicesApp/simplemicroservicesApp.csproj: no such file or directory

the root of cause of this issue is that Visual Studio generated the dockerfile inside the project folder. actually it should be in the solution folder.

by default the dockerfile was generated inside the project folder






actually it should be in the solution level in order to build a docker image properly.





after i cut and paste the file into the solution folder, then navigate to the solution folder in window CMD, and execute the following line to create a docker image.

docker build . -t myimage -f dockerfile



Friday, February 21, 2020

how to get an access token and use the token to access key vault to load secret from Azure CLI (Bash)?

first i create an azure key vault with the following az command

az keyvault create --resource-group myResource-rg --name mykeyvault 

second i can store the secret(for example password) in the key vault

az keyvault secrete create --name dbpassword --vault-name mykeyvault --description "database password" --value "mysecretpassord"


third step is generate the access token to access the key vault

access_token=(curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net' -H Metadata: true -r '.access_toekn')

final step is to use the token to load the password out of key vault
(dbpassword is name of the password set in the key vault secret, mykeyvault is the name of the key vault that i had setup in Azure)

 db_password=$(curl https://mykeyvault.vault.azure.net/secrets/dbpassword?api-version=2016-10-01 -H "Authorization: Bearer $access_token" --silent | jq -r '.value')

how to revoke the disk access in the Azure Replication?

after i complete a lab on  Site Recovery with Azure Replication, I encountered an error when i try clean up the resource.

 "There is an active shared access signature outstanding for disk molvm_disk1_6fd65a43abc14b58857b6beba271a17a-ASRReplica. Call EndGetAccess before attaching or deleting the disk. Learn more here: aka.ms/revokeaccessapi."


the error is stem from the disk had been enable the shared read access for replication

after i run the following command in Azure CLI, then i can successfully remove the resource.

az disk revoke-access --name MyManagedDisk --resource-group MyResourceGroup

for more information, please view the link below

https://docs.microsoft.com/de-de/cli/azure/disk?view=azure-cli-latest#az-disk-revoke-access


Tuesday, February 4, 2020

Azure CLI helpful tips

1. use -h in the az group to show all available options for the command.

C:\Users>az group -h

Group
    az group : Manage resource groups and template deployments.

Subgroups:
    deployment : Manage Azure Resource Manager deployments.
    lock       : Manage Azure resource group locks.

Commands:
    create     : Create a new resource group.
    delete     : Delete a resource group.
    exists     : Check if a resource group exists.
    export     : Captures a resource group as a template.
    list       : List resource groups.
    show       : Gets a resource group.
    update     : Update a resource group.
    wait       : Place the CLI in a waiting state until a condition of the resource group is met.


2. use az interactive to work in the interactive mode.

it is very cool feature to use. even though it is in preview mode. it supports the intelli-sense, it shows the autocomplete during your typing








3. use --output flag to format the output display
when you try to list all account using az account list, the output will be in json format

we can use tsv to show the result in table format.

az account list --output tsv

Sunday, February 2, 2020

How to add Azure Logic App project template in Visual Studio?

1. Launch Visual Studio and click on the Extensions mean tab and select Manage Extensions.



2. Type Logic in the search box and hit enter, then select Azure Logic App Tools for Visual Studio 2019



3. double click on it to install the extension. close the visual studio in order to complete the modification.

4. now you can create a Azure Logic App project in Visual Studio 2019. please Note Azure Logic App Template resides in the Azure Resource Group Project Template. when you create a Azure Resource Group Project, you will direct to the windows to select a Azure Template