|
| 1 | +--- |
| 2 | +title: Disable local authentication with Azure Service Bus |
| 3 | +description: This article explains how to disable local or Shared Access Signature key authentication for a Service Bus namespace. |
| 4 | +ms.topic: how-to |
| 5 | +ms.date: 02/01/2022 |
| 6 | +--- |
| 7 | + |
| 8 | +# Disable local or shared access key authentication with Azure Service Bus |
| 9 | +There are two ways to authenticate to Azure Service Bus resources: Azure Active Directory (Azure AD) and Shared Access Signatures (SAS). Azure AD provides superior security and ease of use over shared access signatures (SAS). With Azure AD, there’s no need to store the tokens in your code and risk potential security vulnerabilities. We recommend that you use Azure AD with your Azure Service Bus applications when possible. |
| 10 | + |
| 11 | +This article explains how to disable SAS key authentication and use only Azure AD for authentication. |
| 12 | + |
| 13 | +## Use portal to disable local auth |
| 14 | +In this section, you learn how to use the Azure portal to disable local authentication. |
| 15 | + |
| 16 | +1. Navigate to your Service Bus namespace in the [Azure portal](https://portal.azure.com). |
| 17 | +1. In the **Essentials** section of the **Overview** page, select **Enabled**, for **Local Authentication**. |
| 18 | + |
| 19 | + :::image type="content" source="./media/disable-local-authentication/portal-overview-enabled.png" alt-text="Image showing the Overview page of a Service Bus namespace with Local Authentication set to Enabled."::: |
| 20 | +1. On the **Local Authentication** page, select **Disabled**, and select **OK**. |
| 21 | + |
| 22 | + :::image type="content" source="./media/disable-local-authentication/select-disabled.png" alt-text="Disable location."::: |
| 23 | + |
| 24 | +## Use Resource Manager template to disable local auth |
| 25 | +You can disable local authentication for a Service Bus namespace by setting `disableLocalAuth` property to `true` as shown in the following Azure Resource Manager template. |
| 26 | + |
| 27 | +```json |
| 28 | +{ |
| 29 | + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
| 30 | + "contentVersion": "1.0.0.0", |
| 31 | + "parameters": { |
| 32 | + "namespace_name": { |
| 33 | + "defaultValue": "spcontososbusns", |
| 34 | + "type": "String" |
| 35 | + } |
| 36 | + }, |
| 37 | + "variables": {}, |
| 38 | + "resources": [ |
| 39 | + { |
| 40 | + "type": "Microsoft.ServiceBus/namespaces", |
| 41 | + "apiVersion": "2021-06-01-preview", |
| 42 | + "name": "[parameters('namespace_name')]", |
| 43 | + "location": "East US", |
| 44 | + "sku": { |
| 45 | + "name": "Standard", |
| 46 | + "tier": "Standard" |
| 47 | + }, |
| 48 | + "properties": { |
| 49 | + "disableLocalAuth": true, |
| 50 | + "zoneRedundant": false |
| 51 | + } |
| 52 | + } |
| 53 | + ] |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +### Parameters.json |
| 58 | + |
| 59 | +```json |
| 60 | +{ |
| 61 | + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", |
| 62 | + "contentVersion": "1.0.0.0", |
| 63 | + "parameters": { |
| 64 | + "namespace_name": { |
| 65 | + "value": null |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Azure policy |
| 72 | +You can assign the [disable local auth](https://portal.azure.com/#blade/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fcfb11c26-f069-4c14-8e36-56c394dae5af) Azure policy to an Azure subscription or a resource group to enforce disabling of local authentication for all Service Bus namespaces in the subscription or the resource group. |
| 73 | + |
| 74 | +:::image type="content" source="./media/disable-local-authentication/azure-policy.png" alt-text="Azure policy to disable location authentication."::: |
| 75 | + |
| 76 | +## Next steps |
| 77 | +See the following to learn about Azure AD and SAS authentication. |
| 78 | + |
| 79 | +- [Authentication with SAS](service-bus-sas.md) |
| 80 | +- Authentication with Azure AD |
| 81 | + - [Authenticate with managed identities](service-bus-managed-service-identity.md) |
| 82 | + - [Authenticate from an application](authenticate-application.md) |
0 commit comments