File size: 3,212 Bytes
db204b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
1- Github pushing files:

a) just delete any old git folder before create new repo
b) cd path/to/your/folder
c) git init
d) git add . 
e) git commit -m "First Commit"
f) git remote add origin https://github.com/your_username/your_repository_name.git
g) git push -u origin master
 
2- In Azure:
a) go to create resource
b) select webapp (name it (resourcegroup,instance)), python 3.8
c) pricing plan P1
d) next, create

3- In Azure:
a) go to create resource
b) select azure bot and create
c) select same resourcegroup
d) next and create
e) go to resource --> configuration --> copy "MicrosoftAppID"/ "Pass"
f) open a new tab --> go to app services --> select the resource --> configuration --> new application setting
g) Name: MicrosoftAppID, Value: Pass
h) in the other tab go to Manage Password, click new secret "name it newsecret" 180 days, copy the value.
i) back to the other tab of webapp --> configuration --> new application setting, pass the value, name "MicrosoftAppPassword"
j) configuration --> new application setting --> SCM_DO_BUILD_DURING_DEPLOYMENT --> True (value)
k) save, and in the same page in general settings, 
start up command "gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP"


##Container##

open azurecli and put the below commands:

# Get the resource group's ID
groupId=$(az group show --name myResourceGroup --query id --output tsv)

# Create the service principal
az ad sp create-for-rbac --scope $groupId --role Contributor --sdk-auth

save the output json credentials

create new container registery: 

registryId=$(az acr show --name myRegistry --resource-group myResourceGroup --query id --output tsv)

#az acr show --name <registry-name> --resource-group <resource-group-name> --query id --output tsv

#az acr show --name myRegistry --resource-group myResourceGroup --query id --output tsv

lisitng: 
acr list
az acr show
az acr list -o table

az acr show --name botapp2 --resource-group ahmedewispybot --query id --output tsv
and i got this, where is the register id?
/subscriptions/be2c9f65-de8d-4413-ab92-57d07fd5a256/resourceGroups/ahmedewispybot/providers/Microsoft.ContainerRegistry/registries/botapp2
The output you received from the command is actually the registryId you were looking for.

So in your case, the registryId is:
/subscriptions/be2c9f65-de8d-4413-ab92-57d07fd5a256/resourceGroups/ahmedewispybot/providers/Microsoft.ContainerRegistry/registries/botapp2


You can use this registryId directly in the role assignment command to assign a role to a service principal.
 For example, if you want to assign the AcrPush role to a service principal with the client ID "abcd1234", you would use the following command:

az role assignment create \
  --assignee <ClientId> \
  --scope $registryId \
  --role AcrPush

<ClientId> from json file


code example of the role assignment:


az role assignment create --assignee abcd1234 --scope /subscriptions/be2c9f65-de8d-4413-ab92-57d07fd5a256/resourceGroups/ahmedewispybot/providers/Microsoft.ContainerRegistry/registries/botapp2 --role AcrPush



https://learn.microsoft.com/en-us/azure/container-instances/container-instances-github-action?tabs=userlevel