Self hosted repository prerequisities
When hosting your API repository in your own DevOps project there are some permissions to set, allowing the api-management-apis Build Service (LKAB)
create and contribute to the repository.
Step 1 Set repository permissions
- Open your DevOps project -> Select
Project settings
in the left menu pane - In the
Repos
section -> SelectRepositories
- On the
All Repositories
page, Select theSecurity
tab - In the
Search for users and groups
input field, enterapi-management-apis Build Service (LKAB)
to find the build user account - Select the
api-management-apis Build Service (LKAB)
user and set permissions to match these settings - Do the same procedure for the
Mockingbird Build Service (LKAB)
user. - Verify permissions match the above
Step 2 Invite to contribute
- Open your DevOps project -> Select
Project settings
in the left menu pane - In the
General
section -> SelectPermissions
- On the
Permissions
page -> SelectContributors
- On the
[Your project name]\Contributor
page -> Select theMembers
tab - Click the
Add
button and search and selectapi-management-apis Build Service (LKAB)
andMockingbird Build Service (LKAB)
in the search field - Click
Save
- Select
Pipelines
in the left menu pane and add permissions for Contributors to edit pipelines
Step 3 Setup Deploy access
Your API deployment pipeline (created in later steps) need permissions to publish your API to Azure. This is accomplished via Service connections
in your DevOps project. These service connections are created by the Add Azure APIM Deploy Access pipeline found in the Mockingbird DevOps project.
Note that this step requires access to the Mockingbird DevOps project. If you don't have access (you probably don't), reach out to the API Management team by sending an email and ask for assistance.
Use this pipeline link or open the Mockingbird
project in DevOps, select Pipelines in the left menu pane and click on the Add Azure APIM Deploy Access
pipeline. Then click the Run pipeline
button.
In the dialog that opens, edit the devOpsProjectName
parameter, ie. replace the $(System.TeamProject)
text with the name of your DevOps project. Then hit the Run
button.
When the pipeline finishes all jobs should be successful, as in the image below. If all fails maybe there is an error that needs to be fixed by the API Management Team but if it's only one or two (or three) you can try to hit the Rerun failed jobs
button.
Updating Service connection key
When Service connections are created they contain a Service principal key (a password) with limited lifetime. When they expire the deploy pipeline no longer have the possibility to publish changes to Azure. When this happens, contact the API Management Team for a new key.
When you have received a new key you must update the Service connection.
- Go to Project settings and then Service connections under the Pipeline section.
- Click on the service connection in question and then the
Edit
button in the upper right corner. - Paste the new key in the
Service principal key
field. - Click on the
Verify and save
button. - Possibly repeat for the other Service connections if you have updated keys for them too
Step 4 Continue with repository creation
Now that all permissions are in place you can continue creating the repository at Step 1 - Prepare and run the Create API Repo pipeline.
Step 5 Clean up
This step is optional, if you don't mind you can leave the permissions as-is.
When the repository is created the above permissions for api-management-apis Build Service (LKAB)
and Mockingbird Build Service (LKAB)
can be removed from the project.
- Go the Project settings and select Repositories under the Repos section
- Select the Security tab
- Click on
api-management-apis Build Service (LKAB)
and the trash bin icon. - Click on
Mockingbird Build Service (LKAB)
and the trash bin icon. - Go to Permissions under the General section
- Click on Contributors and the Members tab
- Use the three dot menu on each row to remove
api-management-apis Build Service (LKAB)
andMockingbird Build Service (LKAB)
via theRemove
action.