|
| 1 | +--- |
| 2 | +title: Create key vault for code signing |
| 3 | +description: Learn how to create Azure key vault for automated code signing of native mobile apps in wrap wizard. |
| 4 | +author: makolomi |
| 5 | +ms.topic: article |
| 6 | +ms.custom: canvas |
| 7 | +ms.reviewer: mkaur |
| 8 | +ms.date: 7/7/2023 |
| 9 | +ms.subservice: canvas-maker |
| 10 | +ms.author: mkaur |
| 11 | +search.audienceType: |
| 12 | + - maker |
| 13 | +contributors: |
| 14 | + - mkaur-msft |
| 15 | +--- |
| 16 | +# Create Azure key vault for wrap in Power Apps |
| 17 | + |
| 18 | +In order to automatically, sign your Android or iOS mobile app package during [Step 2](wrap-how-to.md#step-2-target-platform) of the wrap wizard, it's necessary to have Azure Key Vault configured. Azure Key Vault is a cloud-based service designed to provide a secure storage solution for secrets, which can include certificates, passwords, keys, and other sensitive information. To learn more about Azure Key Vault, see [Introduction to Azure key vault](/azure/key-vault/general/overview). |
| 19 | + |
| 20 | + |
| 21 | +In this article, you will learn how to use an existing Azure key vault or create a new [Azure portal](https://portal.azure.com). |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- Azure Active Directory subscription to [create Key Vault](/azure/key-vault/general/quick-create-portal). |
| 26 | +- Admin access for your tenant. |
| 27 | +- You need to have a [Apple account](https://developer.apple.com) enrolled in Apple developer Program or Apple enterprise developer program. |
| 28 | +- Create a [distribution certificate](code-sign-ios.md#create-the-distribution-certificate) or [ad-hoc Provisioning Profile](code-sign-ios.md#create-an-ios-provisioning-profile) or enterprise provisioning profile. |
| 29 | + |
| 30 | + |
| 31 | +## Create Azure key vault and configure KeyVault URI |
| 32 | + |
| 33 | +1. To create a new Azure service principal for the 1P AAD application **4e1f8dc5-5a42-45ce-a096-700fa485ba20 (WrapKeyVaultAccessApp)**, sign in to your tenant as an admin. Then, run the following script in PowerShell: |
| 34 | + |
| 35 | + `Connect-AzureAD -TenantId <your tenant ID>`<br> |
| 36 | + `New-AzureADServicePrincipal -AppId 4e1f8dc5-5a42-45ce-a096-700fa485ba20 -DisplayName "Wrap KeyVault Access App"` |
| 37 | + |
| 38 | + |
| 39 | +2. Follow these steps to ensure that the Service Principal representing your app, such as Wrap KeyVault Access App, has the necessary access permissions, add a **Reader** role assignment to it in the **Access Control (IAM)** of your default subscription. This should also be present in the IAM of both the subscription and the Keyvault. |
| 40 | + |
| 41 | + 1. On the left select **Access control (IAM)** tab and then select **Add** > **Add role assignment**. |
| 42 | + |
| 43 | + 2. Select the **Members** tab and then select **Job function roles**. Make sure the **Reader** role is selected. |
| 44 | + |
| 45 | + > [!div class="mx-imgBorder"] |
| 46 | + >  |
| 47 | +
|
| 48 | + 4. On **Members** tab, select **Select member** and in the text box on the right enter **Wrap KeyVault Access App** and search for it. |
| 49 | + |
| 50 | + > [!div class="mx-imgBorder"] |
| 51 | + >  |
| 52 | +
|
| 53 | + 5. Select **Wrap KeyVault Access App** and then select **Review + assign** to assign the **Reader** role. |
| 54 | + |
| 55 | + > [!div class="mx-imgBorder"] |
| 56 | + >  |
| 57 | +
|
| 58 | + |
| 59 | +3. Create or access existing key vault. Make sure this key vault is located in the default subscription for your tenant. More information: [Create a key vault using the Azure portal](/azure/key-vault/general/quick-create-portal). |
| 60 | + |
| 61 | +4. Add access policies for the key vault. |
| 62 | + |
| 63 | +5. Choose one of the following options based on your device: |
| 64 | + |
| 65 | + - **Android** |
| 66 | + |
| 67 | + Generate the .pfx file and then proceed to upload it to the certificate section of the keyvault. More information: [Generate keys](code-sign-android.md#generate-keys) |
| 68 | + |
| 69 | + :::image type="content" source="media/wrap-canvas-app/wrap-1.png" alt-text="Create a cert for Android."::: |
| 70 | + |
| 71 | + > [!NOTE] |
| 72 | + > Ensure that the certificate name is included in the tag step and that the password matches the one entered for the store pass parameter used in creating the .pfx file during step 2. |
| 73 | + |
| 74 | + - **iOS** |
| 75 | + 1. Select the .cer into Keychain Access app to install it. For more information, see [Create the distribution certificate](code-sign-ios.md#create-the-distribution-certificate). |
| 76 | + 2. Right-click your certificate file to export the file as a .p12 file, select **Export**, and then select the file format .p12. |
| 77 | + |
| 78 | + > [!NOTE] |
| 79 | + > When you upload to the keyvault, you'll need to provide the password that you set in previous step for the .p12 file. |
| 80 | + |
| 81 | + 3. [Create the provisioning profile](code-sign-ios.md#create-an-ios-provisioning-profile) and run this command to encode it to base64: |
| 82 | + - Mac: base64 `-i example.mobileprovision` |
| 83 | + - Windows: `certutil -encode data.txt tmp.b64` |
| 84 | + |
| 85 | + 4. Upload the `base64` string obtained from the previous step to the Keyvault secret. Next, upload the .p12 file to Keyvault Certificate. |
| 86 | + |
| 87 | + |
| 88 | + :::image type="content" source="media/wrap-canvas-app/wrap-2.png" alt-text="Create a cert for iOS."::: |
| 89 | + |
| 90 | +6. Once iOS or Android certificates are created and uploaded, add three tags with the name as the bundle ID, and the value corresponding to the name of the uploaded certificate(s). |
| 91 | + |
| 92 | + :::image type="content" source="media/wrap-canvas-app/wrap-3.png" alt-text="Add tags."::: |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +### See also |
| 98 | + |
| 99 | +- [Wrap overview](overview.md) |
| 100 | +- [Code sign for iOS](code-sign-ios.md) |
| 101 | +- [Code sign for Android](code-sign-android.md) |
| 102 | +- [Code sign for Google Play Store](https://developer.android.com/studio/publish/app-signing) |
| 103 | +- [Frequently asked questions for wrap](faq.yml) |
0 commit comments