@@ -68,13 +68,13 @@ def deploy_flow(endpoint_name, deployment_name):
6868 "PRT_CONFIG_OVERRIDE" : f"deployment.subscription_id={ client .subscription_id } ,deployment.resource_group={ client .resource_group_name } ,deployment.workspace_name={ client .workspace_name } ,deployment.endpoint_name={ endpoint_name } ,deployment.deployment_name={ deployment_name } " ,
6969 # the following is enabled by secret injection
7070 # make sure your environment variables here match the environment variables your code depends on
71- 'AZURE_OPENAI_ENDPOINT' : os .getenv ( 'AZURE_OPENAI_ENDPOINT' ) ,
72- 'AZURE_SEARCH_ENDPOINT' : os .getenv ( 'AZURE_SEARCH_ENDPOINT' ) ,
73- 'AZURE_OPENAI_API_VERSION' : os .getenv ( 'AZURE_OPENAI_API_VERSION' ) ,
74- 'AZURE_OPENAI_CHAT_DEPLOYMENT' : os .getenv ( 'AZURE_OPENAI_CHAT_DEPLOYMENT' ) ,
75- 'AZURE_OPENAI_EVALUATION_DEPLOYMENT' : os .getenv ( 'AZURE_OPENAI_EVALUATION_DEPLOYMENT' ) ,
76- 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT' : os .getenv ( 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT' ) ,
77- 'AZUREAI_SEARCH_INDEX_NAME' : os .getenv ( 'AZUREAI_SEARCH_INDEX_NAME' )
71+ 'AZURE_OPENAI_ENDPOINT' : os .environ [ 'AZURE_OPENAI_ENDPOINT' ] ,
72+ 'AZURE_SEARCH_ENDPOINT' : os .environ [ 'AZURE_SEARCH_ENDPOINT' ] ,
73+ 'AZURE_OPENAI_API_VERSION' : os .environ [ 'AZURE_OPENAI_API_VERSION' ] ,
74+ 'AZURE_OPENAI_CHAT_DEPLOYMENT' : os .environ [ 'AZURE_OPENAI_CHAT_DEPLOYMENT' ] ,
75+ 'AZURE_OPENAI_EVALUATION_DEPLOYMENT' : os .environ [ 'AZURE_OPENAI_EVALUATION_DEPLOYMENT' ] ,
76+ 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT' : os .environ [ 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT' ] ,
77+ 'AZUREAI_SEARCH_INDEX_NAME' : os .environ [ 'AZUREAI_SEARCH_INDEX_NAME' ]
7878 }
7979 )
8080
@@ -90,20 +90,23 @@ def deploy_flow(endpoint_name, deployment_name):
9090
9191 # 4. provide endpoint access to Azure Open AI resource
9292 create_role_assignment (
93- scope = f"/subscriptions/{ os .getenv ( "AZURE_SUBSCRIPTION_ID" ) } /resourceGroups/{ os .getenv ( "AZURE_RESOURCE_GROUP" ) } /providers/Microsoft.CognitiveServices/accounts/{ os .getenv ( "AZURE_OPENAI_CONNECTION_NAME" ) } " ,
93+ scope = f"/subscriptions/{ os .environ [ "AZURE_SUBSCRIPTION_ID" ] } /resourceGroups/{ os .environ [ "AZURE_RESOURCE_GROUP" ] } /providers/Microsoft.CognitiveServices/accounts/{ os .environ [ "AZURE_OPENAI_CONNECTION_NAME" ] } " ,
9494 role_name = "Cognitive Services OpenAI User" ,
95- principal_id = endpoint .identity .principal_id )
95+ principal_id = endpoint .identity .principal_id
96+ )
9697
9798 # 5. provide endpoint access to Azure AI Search resource
9899 create_role_assignment (
99- scope = f"/subscriptions/{ os .getenv ( "AZURE_SUBSCRIPTION_ID" ) } /resourceGroups/{ os .getenv ( "AZURE_RESOURCE_GROUP" ) } /providers/Microsoft.Search/searchServices/{ os .getenv ( "AZURE_SEARCH_CONNECTION_NAME" ) } " ,
100+ scope = f"/subscriptions/{ os .environ [ "AZURE_SUBSCRIPTION_ID" ] } /resourceGroups/{ os .environ [ "AZURE_RESOURCE_GROUP" ] } /providers/Microsoft.Search/searchServices/{ os .environ [ "AZURE_SEARCH_CONNECTION_NAME" ] } " ,
100101 role_name = "Search Index Data Contributor" ,
101- principal_id = endpoint .identity .principal_id )
102+ principal_id = endpoint .identity .principal_id
103+ )
102104
103105 output_deployment_details (
104106 client = client ,
105107 endpoint_name = endpoint_name ,
106- deployment_name = deployment_name )
108+ deployment_name = deployment_name
109+ )
107110
108111def create_role_assignment (scope , role_name , principal_id ):
109112
@@ -113,7 +116,8 @@ def create_role_assignment(scope, role_name, principal_id):
113116 # Instantiate the authorization management client
114117 auth_client = AuthorizationManagementClient (
115118 credential = credential ,
116- subscription_id = os .getenv ("AZURE_SUBSCRIPTION_ID" ))
119+ subscription_id = os .environ ["AZURE_SUBSCRIPTION_ID" ]
120+ )
117121
118122 roles = list (auth_client .role_definitions .list (
119123 scope ,
@@ -126,13 +130,15 @@ def create_role_assignment(scope, role_name, principal_id):
126130 parameters = RoleAssignmentCreateParameters (
127131 role_definition_id = role .id ,
128132 principal_id = principal_id ,
129- principal_type = "ServicePrincipal" )
133+ principal_type = "ServicePrincipal"
134+ )
130135
131136 # Create role assignment
132137 role_assignment = auth_client .role_assignments .create (
133138 scope = scope ,
134139 role_assignment_name = uuid .uuid4 (),
135- parameters = parameters )
140+ parameters = parameters
141+ )
136142
137143 return role_assignment
138144
0 commit comments