|
| 1 | +--- |
| 2 | +author: eric-urban |
| 3 | +ms.service: azure-ai-speech |
| 4 | +ms.topic: include |
| 5 | +ms.date: 8/11/2024 |
| 6 | +ms.author: eur |
| 7 | +--- |
| 8 | + |
| 9 | +You need to authenticate your application to access Azure AI services. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials. |
| 10 | + |
| 11 | +[!INCLUDE [Azure key vault](~/reusable-content/ce-skilling/azure/includes/ai-services/security/microsoft-entra-id-akv-expanded.md)] |
| 12 | + |
| 13 | +To set the environment variables for your Speech resource key and region, open a console window, and follow the instructions for your operating system and development environment. |
| 14 | + |
| 15 | +- To set the `SPEECH_KEY` environment variable, replace *your-key* with one of the keys for your resource. |
| 16 | +- To set the `END_POINT` environment variable, replace *your-end-point* with one of the regions for your resource. |
| 17 | + |
| 18 | +#### [Windows](#tab/windows) |
| 19 | + |
| 20 | +```console |
| 21 | +setx SPEECH_KEY your-key |
| 22 | +setx END_POINT your-end-point |
| 23 | +``` |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> If you only need to access the environment variables in the current console, you can set the environment variable with `set` instead of `setx`. |
| 27 | +
|
| 28 | +After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before you run the example. |
| 29 | + |
| 30 | +#### [Linux](#tab/linux) |
| 31 | + |
| 32 | +##### Bash |
| 33 | + |
| 34 | +Edit your *.bashrc* file, and add the environment variables: |
| 35 | + |
| 36 | +```bash |
| 37 | +export SPEECH_KEY=your-key |
| 38 | +export END_POINT=your-end-point |
| 39 | +``` |
| 40 | + |
| 41 | +After you add the environment variables, run `source ~/.bashrc` from your console window to make the changes effective. |
| 42 | + |
| 43 | +#### [macOS](#tab/macos) |
| 44 | + |
| 45 | +##### Bash |
| 46 | + |
| 47 | +Edit your *.bash_profile* file, and add the environment variables: |
| 48 | + |
| 49 | +```bash |
| 50 | +export SPEECH_KEY=your-key |
| 51 | +export END_POINT=your-end-point |
| 52 | +``` |
| 53 | + |
| 54 | +After you add the environment variables, run `source ~/.bash_profile` from your console window to make the changes effective. |
| 55 | + |
| 56 | +##### Xcode |
| 57 | + |
| 58 | +For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1. |
| 59 | + |
| 60 | +1. Select **Product** > **Scheme** > **Edit scheme**. |
| 61 | +1. Select **Arguments** on the **Run** (Debug Run) page. |
| 62 | +1. Under **Environment Variables** select the plus (+) sign to add a new environment variable. |
| 63 | +1. Enter `SPEECH_KEY` for the **Name** and enter your Speech resource key for the **Value**. |
| 64 | + |
| 65 | +To set the environment variable for your Speech resource region, follow the same steps. Set `END_POINT` to the endpoint of your resource. For example, `westus`. |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +For more configuration options, see [the Xcode documentation](https://help.apple.com/xcode/#/dev745c5c974). |
| 70 | + |
| 71 | +--- |
0 commit comments