Azure App Service - Setting up Deployment Slots for existing App Service - azure

I have an existing App Service created in Azure, which has a connection string linking to the database, 'Easy Tables' configured, and a whole bunch of custom API methods and table definitions done via the 'App Service Editor'.
I'm at a stage in development where I need to use deployment slots, in order to have separate environments for development, test, and eventually live.
On creating a deployment slot, I have the option of 'Configuration Source' - where I can clone an existing application.
I select my existing app when I choose this option, however my Easy Tables or API configurations are not carried over with it, and it appears I need to set them up again?
Considering that I already do have everything set up in the App Service, how can I transfer the Easy Tables and API methods over to the new deployment slot without recreating each file one by one.
The end goal that I am trying to achieve is an exact duplication of my current web app - pointing to a separate database, having it's own collection of API calls and easy tables - all using the existing app as a starting point, with a URL different to the existing app.

however my Easy Tables or API configurations are not carried over with it, and it appears I need to set them up again?
Answer in short yes. According the Set up staging environments in Azure App Service, we could know the if we choose WebApp as Configuration Source, it copies the configuration info such connectionstring setting, appsetting etc. not the content of the WebApp.
There is no content after deployment slot creation. You can deploy to the slot from a different repository branch, or an altogether different repository. You can also change the slot's configuration. Use the publish profile or deployment credentials associated with the deployment slot for content updates. For example, you can publish to this slot with git.

Related

Do we need multiple Azure API management instances? for DEV, UAT, PROD environment? [yes we do. contains solution]

Do we need multiple Azure API management instances? for DEV, UAT, PROD environment?
If we do, then how do we source control the dev instance and release it to uat & prod programmatically.
My findings on the net and own practice can be summarized as:-
Source control for the dev instance can be obtained, however pushing the same instance to uat apim instance will result in key error, hence the source code for dev apim instance can only be used by dev instance.
Many developer opt to  go to generate the OpenAPI template  from dev apim instance, then import this OpenAPI template into uat apim instance. This still results in manual updates for the backend routing for all the apis (if u got 100 api, wow thats a lot of copy pasting and update to uat api routing).
"do you need multiple instances"? Technically no, you can all do in one instance.
Would I advise you to seperate instances and have dedicated ones per env? Oh yes! (this btw, applies to basically to any component). To save on costs you can probably use Developer SKU for all but prod (depending on what you do on UAT, of course).
How to carry changes from dev to the other stages: This is a topic with many possible ways. What I have implemented in the past in the following:
Developers wanted to use Dev to make manual changes and try them out until they were satisfied.
We used the Git integration all all instances. Once changes on Dev were ready to move to UAT/Test, a commit in the integrated Git was done. This triggered a workflow which would pull the latest version from Dev and push it into the Git repo of UAT.
Do the same for Prod (from UAT) once ready to go live.
I've managed to solve this. Guide is below. Special thanks to silent for pointing to me to the right direction.
Setup API Management for source control release
Glossary
Meaning
pt..5..apim01
Development api management instance
pt..4..apim01
UAT api management instance
https://pt..5..func01.azurewebsites.net/api
Development azure function endpoint
https://pt..4..func01.azurewebsites.net/api
UAT azure function endpoint
In dev API management, if this azure function backend exist, then delete it.
Note*: This az function backend was automatically created when linking the Azure Function and API Management within Azure Function API tab.
This is not useful when we opt for custom front-end api endpoint.
dev apim backend
These azure function key should also be removed, it came together when linking Azure Function and API Management within Azure Function API tab.
Having this key here will prevent source control deployment. You will have error like these (will show deployment in later steps).
key not found
delete azure function key in named values
Add a function endpoint named values.
Named values is like global variables.
coz my reputation here is still noob, SO does not allow me to upload more images. will update images when I can, for now trust your imaginations.
Update api backend redirect with the named value.
From this, pic 1
To this, pic 2
Now for source control deployment, go to the Repository tab in Dev APIM.
pic 1 (Save to Repository)
Generate credential and Clone the repo to local.
pic 1 (Access Credential)
pic 2 (Generate Password)
pic 3 (Clone the repo to your local machine)
Clone the repo for both dev and uat environment, to your local machine with steps above. Final folder structure like below:-
Directory: C:\..\repos\MY_APIM
pt..4..apim01.scm.azure-api.net
pt..5..apim01.scm.azure-api.net
Now copy the content of dev folder and paste/replace the contents in uat folder.
Git Push the changes to UAT apim master branch
Make sure same named values are created in UAT apim, with right values.
pic 1 (the function-endpoint variable we created)
Now in uat apim, perform Deploy to API Management. This will deploy the changes we recently pushed to api uat master branch.
pic 1 (Deploy to API Management)
Upon successful deployment.
pic 1 (Successful deployment)

how can we transform entire web.config from staging slot to production slot in azure?

I have created multiple slots(test, stage and prod) in my azure app service. Similarly I have created respective web.config files for each environment. I am deploying my application through octopus deployment tool in test environment slot, so initially it's picking web.test.config file and it's working fine.
But, I want to swap complete transformation section of web.config file when I swap it to stage or Prod slot while doing swapping through azure portal. Is there any way to do ?
using application setting and connection string of configuration setting, I am able to segregate the setting of each slot. But I am not sure how can I do it for other section like system.identityModel,system.web system.identityModel.services, etc. Therefore I want to replace complete transformation section according to environment while doing swapping.
When I talked with the app service team, they said slots are not meant for this purpose. The main purpose of slots is to allow deployment of new versions with little or no downtime. Or to test new features with a small percentage of the traffic. Not really for different environments, you should use have separate app services for that, to which you deploy separately.

Azure App Services Deployment Slot Transformations

I would like to start using the deployment slots in my Azure App Services for a staging to production task. The problem that I am running into is I can't seem to find a way to do transformations on the web.config outside of the appsetting and connectionstrings. I seem to be missing something, but I need to be able to adjust other configurations, from logging levels, to other integrated config sections.
We currently have been using direct deployments from our build server with msdeploy and Parameters.xml file to do much of this work, however that won't work with deployment slots.
When you create the additional deployment slot, you can clone all settings from the existing instance, or dont copy anything. As per documentation:
"You can clone configuration from any existing slot. Settings that can
be cloned include app settings, connection strings, language framework
versions, web sockets, HTTP version, and platform bitness."
In the new deployment slot, under Settings > Configuration, you can specify any settings here to be specific to the new deployment slot by selecting "Deployment slot setting".

Azure Deployment using Github web.config transformations

In azure web apps, there's a tab called "Deployment option" that allows a push from a github branch to azure web apps.
Currently I'm developing a website in Umbraco and is trying to get this option to work properly.
I have been able to successfully connect connect web app and sync the build from that branch from github.
However, after the deploy, the connection is wrong so I have deduced that it's potentially a connection string problem.
Therefore, is there a way to perform web.config transforms while using this deployment option?
Generally, you should not attempt to transform your web.config with connection strings during deployment, as doing this leaves you with physical files containing secrets (dangerous practice).
Instead, you need to set your connection strings using the Azure Portal (or ARM API). Just keep a 'dummy' entry in your web.config to mark that you have this key, and then override the value with the real connection string in the portal.
See doc for related info.

How to change the redis target when i swap my app service in Microsoft Azure

I'm using the Microsoft app service to deploy my web application,
and it have staging.domain.com and www.domain.com,
but now they are both link to the same redis,
How to I let them link to different redis, when I swap them?
I think it can solved by the app setting.
Is there any best solution or suggestion?
As shown here in the documentation, you can set different settings on different deployment slots in Web Apps, and set them "sticky". That will make them stay in the deployment slot. If you don't mark them sticky, they will swap with the app.
To configure an app setting or connection string to stick to a slot (not swapped), access the Application Settings blade for a specific slot, then select the Slot Setting box for the configuration elements that should stick the slot. Note that marking a configuration element as slot specific has the effect of establishing that element as not swappable across all the deployment slots associated with the app.

Resources