cd Roaster
dotnet ef migrations add Roaster_CreateRoast --context ApplicationDbContext --startup-project Roaster.csproj --project Roaster.csproj -o Infrastructure/Persistence/Migrations
git tag -a 1.1.14 -m "release-1.1.14"
git push --follow-tags
- Execute the scripts below on your database (not on masterm without <>). This effective registers the managed identity as a user in the database server.
CREATE USER "<MANID name>" FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER "<MANID name>";
ALTER ROLE db_dataWRITER ADD MEMBER "<MANID name>";
ALTER ROLE db_owner ADD MEMBER [<MANID name>]
- Assign the managed identity to the web application.
- Create the connection string:
Server=<server address>,1433;Initial Catalog=<database>;Persist Security Info=False;User ID=<MANID Client ID>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Managed Identity";
- Make sure that private network access is enable for the VNET/Subvnet of the web app, on the SQL server.
- Verify that the VNET has the
Microsoft.Sql
service endpoint enabled. - Set the environment variable in the web app, having the name
ConnectionStrings__RoastDb
and set its value to the connection string from point (3).
-
Use the provided templates to deploy into a subscription.
-
Wait for the resources to be deployed.
-
Go to the web app and download the publish profile.
-
Create a new environment in Github.
-
Set the secrets for the new environment in Github:
- Set the
AZURE_WEBAPP_PUBLISH_PROFILE
to the contents of the previously downloaded publish profile. This secret allows the pipeline to deploy to the Azure Web App. - Set the
DATABASE_CONNECTION_STRING
to the connection string of the database. This connection string is used by the CD pipeline to apply migrations. Do not quote the string. Make sure to use single quotes''
around multi words. For example, a connection string should look like:
Server=<server address>,1433;Initial Catalog=<database>;Persist Security Info=False;User ID=<MANID Client ID>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication='Active Directory Managed Identity';
- Set the
-
Set environment specific variables in Github: 1.Set the
AZURE_WEBAPP_NAME
to the resource name of the deployed Azure Web Application. -
Integrate Github with the ACR:
- Create a
push only
token in the ACR. Grant therepositories_push
scope. Usegithub
as default. - Set the
AZURE_CLIENT_ID
secret to the name of the name of the newly created token. - Set the
AZURE_CLIENT_SECRET
secret to thepassword1
orpassword2
of the newly created ACR token. These passwords need to be manually generated inside the portal. - Set the
ACR_URL
variable to the address of the ACR. - Set the
REPOSITORY
variable to the name of the desired repository. Useroaster-api
as default.
- Create a
-
Integrate the web app with the ACR:
- Generate a new
pull only
ACR token. - Set the
DOCKER_REGISTRY_SERVER_USERNAME
andDOCKER_REGISTRY_SERVER_PASSWORD
to the ACR token name and password.
- Generate a new
-
Setup the Web App:
-
Set the connection string environment variable. Set
ConnectionStrings__RoastDb
to the connection string you crafted inDatabase authentication using MANID
. -
Set up the
APPLICATIONINSIGHTS_CONNECTION_STRING
to the connection string from the Application Insights resource.