Create ACR
ACR->Access keys->select Admin user checkbox
Create ACR
ACR->Access keys->select Admin user checkbox
ACR->IAM->Add Role Assignment->acrPull->manabranjanbasu
Install the vs code extension docker. Make sure C# and Azure extensions are installed.
Open the code(world trip client) in vs code-> Make sure it has docker file
Ctrl+shift+p for command pallet ->select Azure container….Azure->Put the name of the image or click on it to accept default name->select subscription->select registry provider as azure->select subscription->select acr you created in the step above->Select image base OS= Linux-> wait to build and deployment and push the image automatically
Create new Environment.
Click Create
It doesn’t have docker file. First you have to add it,
In order to do so, press ctrl+shift+p and then type “docker add docker files to workspace”, then select asp.net core and then linux ->note down the port 5096->include option docker compose=no->hit enter.
It will generate the file below and remove the below red section
Download azure cli from the url below
https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
close the vs code during the installation
Open vs code and typ az in the terminal to check azure cli is installed
Type az login
Type below command
az containerapp up -n worldtripinfo --environment worldtrip-environment --source . --registry-server <ACR_NAME>.azurecr.io -g worldtrip-rg --registry-username=<ACR_NAME> --registry-password=<ACR_PASSWORD>
the explanation of the above command is
azure nameoftheresource upload -nameofthecontainerapp nameoftheenvironment –sourcecodelocationwhichisdot –registryserver or acrname -resourcegroup –username --password
az containerapp up -n worldtripinfo --environment worldtrip-environment --source . --registry-server <ACR_NAME>.azurecr.io -g worldtrip-rg --registry-username=<ACR_NAME> --registry-password=<ACR_PASSWORD>
We already have the below resources created
Copy the registry name, user name and the password
az containerapp up -n worldtripinfo --environment worldtrip-environment --source . --registry-server acrworldtrip.azurecr.io -g worldtrip-rg --registry-username=acrworldtrip --registry-password=a2hPbwNiAmGYXSYw4+nHTB03lz38v0rEJhFF4ZZqdV+ACRCCsgYs
Run the above command in the terminal.
** Work behind the proxy, set below env variable
This typically happens when using Azure CLI behind a proxy that intercepts traffic with a self-signed certificate. Please add this certificate to the trusted CA bundle
REQUESTS_CA_BUNDLE
C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\certifi\cacert.pem
In the powershell admin run the command below
set ADAL_PYTHON_SSL_NO_VERIFY=1
set AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
Run below commands on vs code terminal as well
$env:ADAL_PYTHON_SSL_NO_VERIFY = '1'
$env:AZURE_CLI_DISABLE_CONNECTION_VERIFICATION = '1'
DIDN’T WORK, so done it manually and selected the same acr. The objective was to create below resources
/*container app name= worldtripinfo
env = worldtrip-environmet
registry= acrworldtrip.azurecr.io*/
Now the acr has 2 images
Now create the container app
Once the resource is created, check the url and append the tripInfo at the end and check if the output can be seen
worldtripinfo.yellowsea-23db678c.uksouth.azurecontainerapps.io/tripInfo
Change some text to make sure the latest version is being used after the deployment
Change the API url
Update the CORS policy of the API
Run it locally first
Build and upload the image
Pull the latest image into the container. In order to do so , go to Containers->Edit and Deploy
Select latest image tag
Now go to revisions and check the running status
Refresh the URL and check the latest updates
Click the revision mode
Change the traffic percentage
Go to the Inactive revisions
Click on Activate
Change the traffic percentage and save
Refresh the page multiple times to switch between the revisions
In few minutes, both we be showing as running