Source control in PowerApps can be tricky because it is low-code, so the developer does not have the experience of a repo like GIT.
However, I think I found adequate workarounds that would allow my PowerApps artifacts to be stored in GIT and with not too much work be moved across environments.
A working custom connector can be downloaded as a very complete Swaggger file.
This can then be used to create another custom connector in a different environment, providing exactly the same functionality.
The “trick” for this manual step to be “fast” is that the Swagger was not produced by APIm, say. I found that Swaggers downloaded from APIm are “sketchy” (missing schemas for bodies, for example, or missing host), so if they are used to create a Custom Connector then there is a fair amount of manual work in the wizard to fill out all that was missing.
Instead, use a “complete” Swagger, with all the schemas and fields. This could be authored productively in an IDE.
Once a “complete” Swagger exists and the Custom Connector is created for the first time in Environment #1, it is easy to export it to Environment #2 as follows:
Download the Custom Connector. This will download a Swagger file that is exactly what Environment #1 thinks the Custom Connector is. It will be “complete” since it comes from a working connector.
Now in Environment #2, create a new Custom Connector using that Swagger file. Because it is a “complete”, the wizard in Environment #2 will breeze through it without manually having to fill out things that are missing.
To test the connector in Environment #2, all you now need is the API key for the API behind the custom connector.
PowerApps supports exporting an application as a package. This is basically a zip file with all the UI logic.
However, it excludes Custom Connectors, which should be separately exported as describeda above.
This, to export an application from Environment #1 to Environment #2:
First “export” any custom connectors that it uses, as described above.
Then do an “Export Package” on the app in Environment #1. This is available by choosing “Apps” in the left side bar of PowerApps and selecting the app we want to export. This creates a zip file.
In Environment #2, do an “Import Canvas App” in the Apps area (make sure no app is selected so that this menu item appears). Select the zip file from the previous step. You probably need to correct some things, such as ensuring the app imported is updated (if it already exists in Environment #2) or created (if it does not). For its Custom Connector dependencies you will probably be asked to select Custom Connectors that should already exist in Environment #2 (which is why we first exported the custom connectors before exporting the app, so that by the time the app is imported in Environment #2, there is already the required custom connector in Environment #2).
You probably will be asked to enter an API key for any Custom Connector you choose while importing the app in Environment #2.