Skip to content

Commit 8b18061

Browse files
authored
[Identity] Update Service Fabric manual testing instructions (Azure#21370)
1 parent 3597bb2 commit 8b18061

File tree

1 file changed

+118
-16
lines changed
  • sdk/identity/azure-identity/tests/managed-identity-live/service-fabric

1 file changed

+118
-16
lines changed

sdk/identity/azure-identity/tests/managed-identity-live/service-fabric/service_fabric.md

Lines changed: 118 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@ cd azure-sdk-for-python/sdk/identity/azure-identity/tests/managed-identity-live/
2727
- [Resource setup](#set-up-resources)
2828
- [Application deployment](#set-up-and-deploy-the-applications)
2929
- [Test validation](#run-the-tests)
30+
- [Troubleshooting](#troubleshooting)
3031

31-
## Set Up Resources
32+
## Set up resources
3233

3334
You can skip to [Set Up and Deploy the Applications](#set-up-and-deploy-the-applications) if you have an existing Service Fabric cluster, key vault, storage account, container registry, and managed identity named "AdminUser".
3435

35-
### Create a resource group
36+
### Log in and set the subscription
3637

37-
From a command prompt window, run:
38+
First, we need to log in to the Azure CLI and set the subscription that we want our resources to live in, to make the following steps easier. From a command prompt window, run:
3839
```
3940
az login
40-
az group create -n $RESOURCE_GROUP --location $LOCATION --subscription $SUBSCRIPTION_NAME
41+
az account set -n $SUBSCRIPTION_NAME
42+
```
43+
44+
### Create a resource group
45+
46+
This is only necessary if you don't have a resource group in this location and subscription. From your command prompt window, run:
47+
```
48+
az group create -n $RESOURCE_GROUP -l $LOCATION
4149
```
4250

4351
### Create a user-assigned managed identity
@@ -56,19 +64,20 @@ az identity show -g $RESOURCE_GROUP -n AdminUser
5664

5765
Create your key vault:
5866
```
59-
az keyvault create -g $RESOURCE_GROUP -n $KEY_VAULT_NAME --sku standard --enabled-for-deployment true --enabled-for-template-deployment true
67+
az keyvault create -g $RESOURCE_GROUP -n $KEY_VAULT_NAME -l $LOCATION --sku standard --enabled-for-deployment true --enabled-for-template-deployment true
6068
```
6169

62-
After creating the vault, [create a self-signed certificate](https://docs.microsoft.com/azure/key-vault/certificates/quick-create-portal#add-a-certificate-to-key-vault) in it using the [Azure Portal](https://portal.azure.com/). You'll need to insert some of this certificate's properties into the cluster template later on.
70+
After creating the vault, [create a self-signed certificate](https://docs.microsoft.com/azure/key-vault/certificates/quick-create-portal#add-a-certificate-to-key-vault) in it using the [Azure Portal](https://portal.azure.com). You'll need to insert some of this certificate's properties into the cluster template later on.
6371

6472
### Create an Azure Container Registry
6573

6674
From your command prompt window, run:
6775
```
68-
az acr create -g $RESOURCE_GROUP -n $ACR_NAME --admin-enabled --sku basic
76+
az acr create -g $RESOURCE_GROUP -n $ACR_NAME -l $LOCATION --admin-enabled --sku basic
6977
```
7078

71-
_Warning: ACR accounts with uppercase letters in their name may have authentication issues._
79+
> **NOTE:** Don't use upper-case letters in the name of the container registry. A registry can be created with a name
80+
> that includes upper-case letters, but you may be unable to authenticate to it.
7281
7382
### Deploy a managed identity-enabled cluster
7483

@@ -80,12 +89,12 @@ To use the provided template:
8089
2. In `arm-templates/cluster.parameters.json`, change all instances of `sfmi-test` to a unique name, like `<myusername>-sfmi-test`. Also, change the values of `applicationDiagnosticsStorageAccountName` and `supportLogStorageAccountName` to be similarly unique, but without hyphens. This will help ensure the deployment resource names do not conflict with the names of other public resources.
8190
3. Start the deployment by running the following command in your command prompt:
8291
```
83-
az deployment group create --resource-group $RESOURCE_GROUP --template-file arm-templates\cluster.template.json --parameters arm-templates\cluster.parameters.json
92+
az deployment group create -g $RESOURCE_GROUP -f arm-templates\cluster.template.json -p arm-templates\cluster.parameters.json
8493
```
8594

8695
This will begin to deploy a Service Fabric cluster as well as other necessary resources: a load balancer, public IP address, virtual machine scale set, virtual network, and two storage accounts.
8796

88-
## Set Up and Deploy the Applications
97+
## Set up and deploy the applications
8998

9099
### Build and publish a Docker image for each application
91100

@@ -155,8 +164,8 @@ To use the provided templates:
155164
2. Open `arm-templates/sfmitestuser.parameters.json` and complete the same fields, using the URL of `sfmitestuser.sfpkg` for `applicationPackageUrl`.
156165
3. Start the deployment by running the following commands in your command prompt:
157166
```
158-
az deployment group create --resource-group $RESOURCE_GROUP --template-file arm-templates\sfmitestsystem.template.json --parameters arm-templates\sfmitestsystem.parameters.json
159-
az deployment group create --resource-group $RESOURCE_GROUP --template-file arm-templates\sfmitestuser.template.json --parameters arm-templates\sfmitestuser.parameters.json
167+
az deployment group create -g $RESOURCE_GROUP -f arm-templates\sfmitestsystem.template.json -p arm-templates\sfmitestsystem.parameters.json
168+
az deployment group create -g $RESOURCE_GROUP -f arm-templates\sfmitestuser.template.json -p arm-templates\sfmitestuser.parameters.json
160169
```
161170

162171
### Give the applications access to your key vault
@@ -182,13 +191,67 @@ az identity show -g $RESOURCE_GROUP -n AdminUser
182191
az keyvault set-policy -n $KEY_VAULT_NAME --secret-permissions list --object-id $PRINCIPAL_ID
183192
```
184193

185-
## Run the Tests
194+
## Run the tests
195+
196+
### Connect to your cluster on Service Fabric Explorer
197+
198+
Instructions on connecting to the Explorer can be found
199+
[here](https://docs.microsoft.com/azure/service-fabric/service-fabric-connect-to-secure-cluster#connect-to-a-secure-cluster-using-service-fabric-explorer).
200+
Adding a certificate to your local machine's browser is the recommended method of easily connecting to the Explorer;
201+
instructions are below.
202+
203+
#### Add your self-signed certificate to your certificate store
204+
205+
First, go to the Key Vault you created earlier in the Azure Portal. Go to the "Certificates" page in the sidebar and
206+
click on the certificate that you created earlier. Click on the current version of the certificate, and then click
207+
"Download in PFX/PEM format" at the top of the following page.
208+
209+
After the certificate finishes downloading, open your browser's settings and find the option to manage HTTPS/SSL
210+
certificates. On Windows, you should see a window open with a list of certificates in your Personal store -- click
211+
"Import..." to open the Certificate Import Wizard. Browse your files to find the PFX certificate you downloaded from
212+
Key Vault -- you may need to change the file extension filter to "Personal Information Exchange (\*.pfx;\*.p12)".
213+
Import the certificate into your Personal store.
214+
215+
#### Troubleshooting: gain access to the Explorer endpoint
216+
217+
If you're using a corporate VPN and your browser can't connect to the Explorer endpoint because your request times out,
218+
you may have to add a security rule to the network security group resource in your resource group (its name should
219+
begin with "NRMS"). Be sure to first comply with
220+
[security rules for ARM subnets](https://strikecommunity.azurewebsites.net/articles/3427/faq-simply-secure-network-security-rules-for-new-a.html).
221+
[Here](https://strikecommunity.azurewebsites.net/articles/4889/can-not-access-my-non-production-resources-from-so-1.html)
222+
is a page that discusses the known issue with VPN access to some resources.
223+
224+
To add a security rule, open the resource in the Azure Portal, and then go to the "Inbound security rules" page in the
225+
sidebar. Click "Add" to add a new rule, and fill in the following settings:
226+
227+
- **Source:** IP Addresses
228+
- **Source IP addresses/CIDR ranges:** [Your IP address]
229+
- **Source port ranges:** *
230+
- **Destination:** Any
231+
- **Service:** Custom
232+
- **Destination port ranges:** *
233+
- **Protocol:** Any
234+
- **Action:** Allow
235+
- **Priority:** [Lower number than the priority of other rules -- most likely 100]
236+
- **Name:** Allow-My-Machine
237+
238+
#### Connect to Service Fabric Explorer
239+
240+
After adding the certificate to your Personal store (and possibly adding a security rule), going to the Explorer
241+
endpoint in your browser should present you with a page saying that the website is unsafe. This is because the Service
242+
Fabric cluster is providing the self-signed certificate you created with your Key Vault, so this isn't an issue.
243+
Proceed to the website (you may have to expand "Advanced" settings to do this).
244+
245+
You should be prompted for a certificate. Provide the certificate from your Key Vault that you imported to your
246+
machine's certificate store.
247+
248+
### Verify test output
186249

187250
Once running on your cluster, the applications should each perform the same task: using a `ManagedIdentityCredential` to list your key vault's secret properties. One uses a system-assigned managed identity to do so, while the other uses a user-assigned managed identity. To verify that they have each done their job correctly, you can access the application logs in your cluster's Service Fabric Explorer page.
188251

189252
Verify in a browser:
190253

191-
1. [Connect to your cluster on Service Fabric Explorer](https://docs.microsoft.com/azure/service-fabric/service-fabric-connect-to-secure-cluster#connect-to-a-secure-cluster-using-service-fabric-explorer).
254+
1. Connect to your cluster on Service Fabric Explorer.
192255
2. In the Explorer, you should see the applications running under the Applications tab. Otherwise, you may need to double check your deployment process.
193256
3. Under the Nodes tab, expand each node tab to see if it hosts an application ("fabric:/sfmitestsystem" or "fabric:/sfmitestuser").
194257
4. When you find an application entry, click the "+" sign by the name to expand it. There should be a "code" entry -- click on that to bring up a page that has a "Container Logs" tab.
@@ -210,7 +273,46 @@ docker push $ACR_NAME.azurecr.io/sfmitestuser
210273
```
211274
5. Re-deploy the applications:
212275
```
213-
az deployment group create --resource-group $RESOURCE_GROUP --template-file arm-templates\sfmitestsystem.template.json --parameters arm-templates\sfmitestsystem.parameters.json
214-
az deployment group create --resource-group $RESOURCE_GROUP --template-file arm-templates\sfmitestuser.template.json --parameters arm-templates\sfmitestuser.parameters.json
276+
az deployment group create -g $RESOURCE_GROUP -f arm-templates\sfmitestsystem.template.json -p arm-templates\sfmitestsystem.parameters.json
277+
az deployment group create -g $RESOURCE_GROUP -f arm-templates\sfmitestuser.template.json -p arm-templates\sfmitestuser.parameters.json
215278
```
216279
6. Verify the test output again, as you did above. You should now also see that `test_managed_identity_live_async` shows `PASSED`.
280+
281+
## Troubleshooting
282+
283+
**Applications and/or nodes are in an error state**
284+
285+
This usually means that the applications are crashing or the Docker image is broken.
286+
- Validate that you can run the tests locally and only see expected failures/errors for your environment.
287+
- Validate that your Dockerfile has installed all necessary packages for the commands it attempts to run and that it
288+
builds properly. Ensure any endpoints that are referenced by the Dockerfile are available (i.e. make sure URLs
289+
are correct and that install commands will succeed locally). Double-check that commands are formatted correctly.
290+
291+
To push updates to the applications, deployed applications will first need to be deleted.
292+
- In the Explorer, navigate down the "Applications" tab on the sidebar and expand "sfmitestsystemType". Click on
293+
"fabric:/sfmitestsystem". In the top right of the following page, click on "Actions" and then "Delete
294+
Application".
295+
- After the application is deleted, click on "sfmitestsystemType" and in the top right of the following page, click
296+
on "Actions" and then "Unprovision Type".
297+
- Repeat the above steps for `sfmitestuser`.
298+
- Re-deploy the applications after making any changes to your test and/or Docker images, using the deployment
299+
commands in [Deploy the applications](#deploy-the-applications).
300+
301+
**The container logs page is showing an Error 404 upon refresh**
302+
303+
This is normal behavior, and just means that logs aren't available at that time. After refreshing for a while, logs
304+
should appear.
305+
306+
**The Explorer page won't connect or the browser is blocking the endpoint**
307+
308+
Refer to [Connect to your cluster on Service Fabric Explorer](#connect-to-your-cluster-on-service-fabric-explorer).
309+
310+
If you're unable to get any information from the Explorer, there are also cluster logs that can be downloaded from one of the storage accounts that was deployed with the ARM template. These logs are composed of large text files that are very dense, but they can contain information about cluster failures that may help to diagnose problems.
311+
312+
- First, go to the resource group containing the Service Fabric cluster in the Azure Portal.
313+
- Open up the storage account that's dedicated to logs. Its name matches `supportLogStorageAccountName` from `arm-templates/cluster.parameters.json`.
314+
- Open the page of containers in the account. There should be a container with a name indicating that it contains cluster logs.
315+
- Open the logs container. There should be a number of `.dtr` files. Each of these is a log file for a particular time range.
316+
- Download a log file from a time when the cluster should have been attempting to run the test application.
317+
- Open the log file locally using a text reader like Notepad (you may need to unzip it from a compressed folder first).
318+
- Search for phrases that may be associated with an application event or failure. For example, you may want to search for the string "error" and iterate through instances until an event suggests that it was associated with the test application.

0 commit comments

Comments
 (0)