You have a GitHub repository.You need to ensure that all changes to code are validated by your company's security department before the main branch is deployed.Which two actions can you perform? Each correct answer presents a complete solution.Note: Each correct selection is worth one point.
Answer(s): D,E
* Create a CODEOWNERS file.About code ownersYou can use a CODEOWNERS file to define individuals or teams that are responsible for code in a repository.Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.* Create a branch protection rule for the main branchAbout protected branchesYou can protect important branches by setting branch protection rules, which define whether collaborators can delete or force push to the branch and set requirements for any pushes to the branch, such as passing status checks or a linear commit history.
https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your- repository/about-code-owners https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing- protected-branches/about-protected-branches
HOTSPOT (Drag and Drop is not supported)You have a .NET app named App1.You need to upload App1 to GitHub Packages.How should you complete the command? To answer, select the appropriate options in the answer area.Note: Each correct selection is worth one point.Hot Area:
Answer(s): A
The dotnet nuget push command pushes a package to the server and publishes it. The push command uses server and credential details found in the system's NuGet config file or chain of config files.Box 1: dotnetWe publish the package to GitHub packages. Using "dotnet nuget push", with the NuGet package location, defaulting the api-key to GITHUB_TOKEN again, and specifying the source "github" (that we just setup in step3).- name: Publish to GitHub packages run: dotnet nuget push DemoLibrary/DemoLibrary/bin/Release/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"Box 2: nuget push
https://samlearnsazure.blog/2021/07/27/publishing-a-nuget-package-to-github-packages/ https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push
SIMULATIONInitialize the default main branch, if it does not exist already.In the User1-12345678 Azure DevOps project, you need to implement an approval process for the default main branch.The process must use the four-eyes principle and have at least one approval on every iteration.
Azure DevOps, Azure Repos, Branch policies and settingsConfigure branch policiesPhase 1. Select the correct branchStep 1: To manage branch policies, select Repos > Branches to open the Branches page in the web portal.(You can also get to branch policy settings with Project Settings > Repository > Policies > Branch Policies > <Branch Name>.)Step 2: To set branch policies, locate the branch you want to manage. You can browse the list or search for your branch in the Search branch name box at upper right. [Select the default main branch]Select the More options icon next to the branch, and then select Branch policies from the context menu.Phase 2: Configure approvalRequire a minimum number of reviewersCode reviews are important for software development projects. To ensure that teams review and approve PRs, you can require approval from a minimum number of reviewers. The basic policy requires that a specified number of reviewers approve the code, with no rejections.Step 3: To set the policy, under Branch Policies, set Require a minimum number of reviewers to On. Enter the required number of reviewers, and select any of the following options:3a. [Select: Minimum number of reviewers: 2]3b. [Select: When new changes are pushed:]3c [Select Require at least one approval on the last approval of the last iternation]
https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies
SIMULATIONInitialize the default main branch, if it does not exist already.For Project1, you need to implement branch merging restrictions to enable squash merge for all changes merged into the main branch.
Phase 1. Select the correct branchStep 1: To manage branch policies, select Repos > Branches to open the Branches page in the web portal.(You can also get to branch policy settings with Project Settings > Repository > Policies > Branch Policies > <Branch Name>.)Step 2: To set branch policies, locate the branch you want to manage. You can browse the list or search for your branch in the Search branch name box at upper right. [Select the default main branch]Select the More options icon next to the branch, and then select Branch policies from the context menu.Phase 2: Limit merge typesAzure Repos has several merge strategies, and by default, all of them are allowed. You can maintain a consistent branch history by enforcing a merge strategy for PR completion.Step 3: Set Limit merge types to On to limit which merge types to allow in your repo.Step 4: Select Squash merge, deselect the other Allowed Merge types.Squash merge creates a linear history with a single commit in the target branch with the changes from the source branch. Learn more about squash merging and how it affects branch history.
DRAG DROP (Drag and Drop is not supported)You have a GitHub repository named repo1 and an Azure key vault named kv1.In repo1, you plan to create a workflow named Workflow1 that will deploy a database server by using credentials stored in kv1.You need to ensure that Workflow1 can retrieve the credentials from kv1.Which three actions should you perform in sequence? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.Note: More than one order of answer choices is correct. You will receive credit for any of the correct orders you select.Select and Place:
With the Get Key Vault Secrets action, you can fetch secrets from an Azure Key Vault instance and consume in your GitHub Action workflows.Step 1: Create a service principal in Microsoft Entra IdTo fetch the credentials required to authenticate with Azure, run the following command to generate an Azure Service Principal (SPN) with Contributor permissions:az ad sp create-for-rbac --name "myApp" --role contributor \--scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \ --sdk-authStep 2: Grant secret permissions to kv1.Enable permissions to access the Key Vault secretsProvide explicit access policies on the above Azure service principal to be able to access your Key Vault for get and list operations. Use below command for that:az keyvault set-policy -n $KV_NAME --secret-permissions get list --spn <clientId from the Azure SPN JSON>Step 3: Reference the credentials in Workflow1.Reference secret stored in key vaultThe following properties are supported when you configure a field in linked service referencing a key vault secret:Note: Store credentials in Azure Key VaultStepsTo reference a credential stored in Azure Key Vault, you need to:1. Retrieve data factory managed identity by copying the value of "Managed Identity Object ID" generated along with your factory. If you use ADF authoring UI, the managed identity object ID will be shown on the Azure Key Vault linked service creation window; you can also retrieve it from Azure portal, refer to Retrieve data factory managed identity.2. Grant the managed identity access to your Azure Key Vault. In your key vault -> Access policies -> Add Access Policy, search this managed identity to grant Get and List permissions in the Secret permissions dropdown. It allows this designated factory to access secret in key vault.3. Create a linked service pointing to your Azure Key Vault. Refer to Azure Key Vault linked service.4. Create the data store linked service. In its configuration, reference the corresponding secret stored in Azure Key Vault.
https://github.com/Azure/get-keyvault-secrets https://learn.microsoft.com/en-us/azure/data-factory/store-credentials-in-key-vault#reference-secret-stored-in- key-vault
Post your Comments and Discuss Microsoft AZ-400 exam prep with other Community members:
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the AZ-400 content, but please register or login to continue.